link_to for calling an action, instead of a button_to

Posted by Brian Roisentul on Stack Overflow See other posts from Stack Overflow or by Brian Roisentul
Published on 2010-05-20T19:45:41Z Indexed on 2010/05/20 23:40 UTC
Read the original article Hit count: 247

Filed under:

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&Aacute;S RELEVANTES', search_filter_relevance_path %>

My routes file looks like this:

map.search_filter_relevance "/anuncios/buscar", :controller => 'announcements', :action => 'search_filter_relevance'

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.

© Stack Overflow or respective owner

Related posts about ruby-on-rails