In my newscontroller I have two lists category_list and news_list def category_list sort_init ''name'' sort_update end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
sorry i pressed enter wrongly In my newscontroller I have two lists category_list and news_list def category_list sort_init ''name'' sort_update ... :order => sort_clause end def news_list sort_init ''title'' sort_update ... :order => sort_clause end The problem is that when i try to see the news_list the sorthelper sort by name that doesn''t exist in the news table or vice versa any suggestions for this? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
claudio wrote:> sorry i pressed enter wrongly > > > In my newscontroller I have two lists category_list and news_list > def category_list > sort_init ''name'' > sort_update > ... :order => sort_clause > end > > def news_list > sort_init ''title'' > sort_update > ... :order => sort_clause > end > > The problem is that when i try to see the news_list the sorthelper sort > by name that doesn''t exist in the news table or vice versa > > any suggestions for this?I figured out by myself, in the SortHelper.rb in sort_update method on line 92 youo have to modify elseif session[@sort_name] in elseif session[@sort_name][:key] == @sort_default[:key] because you change one list to another one the sorthelper take the last key in the session without update. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > I figured out by myself, in the SortHelper.rb in sort_update method on > line 92 > youo have to modify > elseif session[@sort_name] > in > elseif session[@sort_name][:key] == @sort_default[:key] > > because you change one list to another one the sorthelper take the last > key > in the session without update.i figured out one more time: this up is wrong the correct way is: def sort_update() if params[:sort_key] sort = {:key => params[:sort_key], :order => params[:sort_order]} elsif session[@sort_name] if session[@sort_name][:key] == @sort_default[:key] sort = session[@sort_name] else sort = @sort_default end else sort = @sort_default end session[@sort_name] = sort end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---