Order by with first_name and also last_name

22 views
Skip to first unread message

keerthi priya

unread,
Jan 18, 2013, 6:13:53 AM1/18/13
to rubyonra...@googlegroups.com
Hi all,

 hey I have need some info
i have this
def fullname
 "#{first_name} #{last_name}"
end
and i want alphabetical order with first name i can do it but along with first_name i want last_name in alphabetical order
like
James emi will come first before James fame
can we do in rails

Cheers,
Kp

Loganathan Sellapa

unread,
Jan 18, 2013, 6:19:00 AM1/18/13
to Rails

Model.all(:order => 'first_name DESC, last_name DESC') and then do the interpolation

regards,
Loganathan
Mob: +91 7760780741 | +91 9944414388
Skype: loganathan.sellappa
ViewMe





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/B3d8HeeRUusJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

vikram jaijn

unread,
Jan 18, 2013, 6:30:01 AM1/18/13
to rubyonra...@googlegroups.com
Hi,
Please do this :
Client.order("first_name ASC, last_name ASC")
--
Thanks & Regard
   Vikram Jain
=============
Reply all
Reply to author
Forward
0 new messages