Reputation: 19456
In my Rails 3 application, I've got current_account.users
.
What I want is a list of the names of all the users i.e. user.full_name
. What's the most elegant way to do it?
Upvotes: 0
Views: 2044
Reputation: 5182
If full_name is a column on the model, you can use the pluck
method. That would look like current_account.users.pluck(:full_name)
. If not, you can use map
or collect
(same thing), which would look like current_account.users.map(&:full_name)
or current_account.users.collect(&:full_name)
.
Upvotes: 5