How can i map two columns in single rails query.
Eg.
@profiles = Profile.all.map(&:user_firstname)
After running this query i would able to get users_firstname form table(which is right).
But how can i add users_firstname and users_lastname in above query.If I understood correctly, you can do:
@profiles = Profile.all.map{|p| "#{p.users_firstname} #{p.users_lastname}"}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With