I have one route in my Rails 4 application that is no longer working. It works in my development environment and use to work in my production environment but no longer does.

The error looks like:

ActionView::Template::Error (No route matches {:action=>"profile", :controller=>"business"}):

It occurs in my business/profile view on this line, which use to work.

<%=link_to dba.name, {:controller => 'business', :action => 'profile' },  :id => dba.site_link, :uid => dba.unique_id, :class => "blue-orange-link", :target => "_blank"%>

By the way, I’ve moved the “}” to follow “:uid=>dba.unique_id” as well and that didn’t resolve the issue.

I raked my routes and it does display route.

get '/business/profile/:id/:uid'   => 'business#profile'

I’ve searched and can’t find anything similar to my issue. Typically the answers involved making sure the route was defined, which isn’t my problem. I downloaded my app from my server just to search it to ensure there were no naming conflicts. Any suggestions would be appreciated.

1 comment
  • I have run across this as well when a user has used a forward slash '/' in the text for a permalink field.

    By moving the end brace '}' after the :id => dba.site_link in the first fix it became part of the url hash. The :uid => dba.unique_id was in the html_options hash so you would not have the :uid value in the url.

    By moving the curly brace ' } ' after the :uid => dba.unique_id you had all of the parameters for the full URL.

    link_to signature:
    options is the URL options.

    link_to(name = nil, options = nil, html_options = nil, &block)
    

    Handy link_to signatures (Rails v4.2.1) from apidoc.com

    Cheers.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

UPDATE: PROBLEM SOLVED. Moved the “}” after the parameters in the link and things began working again. It isn’t clear why it stopped working and started working again but here is the change.

<%=link_to dba.name, {:controller => 'business', :action => 'profile' ,  :id => dba.site_link, :uid => dba.unique_id}, :class => "blue-orange-link", :target => "_blank"%>
Submit an Answer