Is there anyway to change sort_link output params?
I wanna make a page that contains more than 开发者_开发知识库one tables. Each table is ajax filtered table that can be sorted using metasearch. This is sorting link for each table. Controller SomeController:
def index
@search = FirstTable.search(params[:search])
@first_tables = @search.all
@search_second_table = SecondTable.search(params[:search_second_table])
@second_tables = @search_second_table.all
...
end
View:
# First table
sort_link @search, :some_attribute, "Some Attribute"
#=> www.example.com/some_controller?search[meta_sort]=some_attribute.asc
# Second table
sort_link @search_second_table, :some_attribute, "Some Attribute"
#=> www.example.com/some_controller?search[meta_sort]=some_attribute.asc
I have no idea why the sort_link outputting the same link or maybe I've made some mistake. Is there anyway to change the output of second_table sort_link to be like this.
#=> www.example.com/some_controller?search_second_table[meta_sort]=some_attribute.asc
Thx for your help.
solved my problem using link_to
. after click "Some Attribute" link, change the "meta_sort" params to desc using jquery, right after ajax response return successfully. link_to "Some Attribute", :controller => "some_controller", :search_second_table => {:meta_sort => "some_attribute.asc"}
精彩评论