Unable to list the names using Search logic

6 views
Skip to first unread message

keerthi priya

unread,
Dec 6, 2012, 1:27:49 AM12/6/12
to rubyonra...@googlegroups.com
Hey all,
          I am trying to list students in alphabetical order starting from a to z but using search logic I unable to do that. can any one help me out.
          These lines are in controller

           @search = Student.search(params[:search])
          @students+=@search.all

View
    <% @students= @students.sort_by(&:last_name) %>
 i am able to sort it but not in alphabetical order. Help me


Cheers,
Kp

Colin Law

unread,
Dec 6, 2012, 4:56:52 AM12/6/12
to rubyonra...@googlegroups.com
What do you mean that you *are* able to sort it but not in
alphabetical order? Please explain what is happening and what you
expect to happen. Give a short example if necessary. Note that it
would be better to do the sort in the controller rather than the view
unless you have a good reason for doing it in the view.

Colin

keerthi priya

unread,
Dec 10, 2012, 1:17:11 AM12/10/12
to rubyonra...@googlegroups.com
Thanks Colin. I have Fixed it.


--
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.

Reply all
Reply to author
Forward
0 new messages