link_to for calling an action, instead of a button_to
I'd like to call an action with a link_to button without being redirected to another page(I don't want ajax). For you to have an idea, I'm trying to accomplish a sort "link button" in a search page. So, when the link is clicked, the page should be refreshed showing the list ordered as I tell it in the action.
If I do the following in my view, it will ask me for a template called as the action, and I don't want it:
<%= link_to 'MÁS RELEVANTES', search_filter_relevance_path %>
My routes f开发者_高级运维ile looks like this:
map.search_filter_relevance "/anuncios/buscar", :controller => 'announcements', :action => 'search_filter_relevance'
EDIT:
If I change the above line to:
map.search_filter_relevance "/anuncios/search_filter_lowest_price", :controller => 'announcements', :action => 'search_filter_relevance'
it access to the action I want it to access, but I can't figure out a way to pass the collection of items I have in the view(it's a search result) to the action, so I can filter them.
And my controller looks like this(I haven't developed the functionality yet):
def search_filter_relevance
end
Any help on this will be appreciated.
I believe you should define what you'll render... an action
, a partial
, nothing
?
def search_filter_relevance
render :action => "some_action"
# or
render :partial => "some_partial"
# or
render :nothing => true
end
Something like that...
Maybe you could explain what you want this action to do exactly...
精彩评论