I'm working with Ruby on rails 2.3.4 and I'd like to have a link that executes an action when clicked.
The relevant part of the routes.rb file looks like this:
map.search_filter_relevance "/anuncios/buscar", :controller => 'announcements', :action => 'search_filter_relevance'
My view(it's the model's index page) looks like this:
<%= link_to 'MÁS RELEVANTES', search_filter_relevance_path %>
And my controller looks like this:
def search_filter_relevance
raise params.inspect
unless params[:announcements].nil? or params[:announcements].empty?
@announcements = params[:announcements].order_by_featured
end
end
The problem is that when I click the link I get an error due to some null value in the Show action! I'm not accessing that action at all...why is executing it?
EDIT:
Here is the routes output:
search_filter_relevance_announcements GET /anuncios/search_filter_relevance(.:format) {:controller=>"announcements", :action=>"search_filter_relevance"}
announcements GET /anuncios(.:format) {:controller=>"announcements", :action=>"index"}
POST /anuncios(.:format) {:controller=>"announcements", :action=>"create"}
new_announcement GET /anuncios/new(.:format) {:controller=>"announcements", :action=>"new"}
edit_announcement GET /anuncios/:id/edit(.:format) {:controller=>"announcements", :action=>"edit"}
announcement GET /anuncios/:id(.:format) {:controller=>"announcements", :action=>"show"}
PUT /anuncios/:id(.:format) {:controller=>"announcements", :action=>"update"}
DELETE /anuncios/:id(.:format) {:controller=>"announcements", :action=>"destroy"}
search /anuncios/buscar {:controller=>"announcements", :action=>"search"}
power_search /anuncios/buscar {:controller=>"announcements", :action=>"power_search"}