SortHelper Problem with column name

In my newscontroller I have two lists category_list and news_list

def category_list
sort_init ‘name’
sort_update

end

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?

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.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs