Topic: map()

Hi,
how can i map first_name and last_name to full_name?

works:

users = user.friendships.map(&:first_name).join(", ")

not working

users = user.friendships.map(&:first_name, :last_name).join(", ")

thanks for helping

pete

Re: map()

What are the relations between User and Friendship models?
What are the attributes in the both models?

I suppose that ONE user has MANY friendships; In this case, when you call 'friendships' on a 'user':

users = user.friendships

you will get an Array of Friendship objects. And of course, calling (mapping) 'first_name' and 'last_name' methods on Friendship object raise an exception. You should call those methods on a User object if you have corresponding attributes/columns/methods defined in User model.

Re: map()

The idea you shared here is amazing, I appreciate your kind way of knowledge sharing!
Essay writing help  online essay writers  Custom essay writing  Buy essay online  University essay

Re: map()

I am doing research on this topic ,too.Your article have given me a lot of inspiration
seo agency  copywriting services uk

Re: map()

you will get an Array of Friendship objects. And of course, calling <a href=