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()

Guarda Moveis tanks for this siteoutsourcing de impressao tanks for this site nice
desenvolvimento para iphone tanks for this site
acompanhantes salvador tanks for this site
Mudanca em Sao Paulo tanks for this site