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 -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Rj9Qh0KXBWkJ. For more options, visit https://groups.google.com/groups/opt_out.
On 6 December 2012 06:27, keerthi priya <emailtokeerthipriya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 meWhat 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 -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Thanks Colin. I have Fixed it. On Thu, Dec 6, 2012 at 3:26 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 6 December 2012 06:27, keerthi priya <emailtokeerthipriya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > 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 > > 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 > > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.