How to program a Sort feature

Posted by Brian Roisentul on Stack Overflow See other posts from Stack Overflow or by Brian Roisentul
Published on 2010-05-20T14:09:14Z Indexed on 2010/05/20 14:10 UTC
Read the original article Hit count: 189

Filed under:

I'm working on Ruby on rails 2.3.4 and I'm trying to develop a Sort feature on my website's search page(its url is /anuncios/buscar).

What I tried is to create a "map" on routes file:

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

Then, I wrote this on the view:

<%=  link_to 'M&Aacute;S RELEVANTES', search_filter_relevance(@announcements) %>

And finally, I created a method in the controller, as is specified on the routes' line:

  def search_filer_relevance
    raise params.inspect
  end

First of all, as I'm sorting search results, I'd like to keep them in their public variable called @announcements. Please help me do this.

An the other thing is that when I click the link I get an error due its trying to access the Show action instead of search_filter_relevance as specified in routes. Why is this happening?

© Stack Overflow or respective owner

Related posts about ruby-on-rails