Link redirects to "show" action instead of the indicated in routes.rb
Posted
by Brian Roisentul
on Stack Overflow
See other posts from Stack Overflow
or by Brian Roisentul
Published on 2010-05-20T17:05:59Z
Indexed on
2010/05/20
17:10 UTC
Read the original article
Hit count: 236
ruby-on-rails
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?
© Stack Overflow or respective owner