Pontek
Pontek

Reputation: 149

Weird route malfunction, mix between devise and own controller

I've got a real weird route behavior. I spotted the line which, i think, cause the error.
Here is the line (in application.html.erb) in question :

<%= link_to "Official Top", :controller => "tops", :action => "show", :id => 10 %>

The problem happens when i want to sign in with devise, when i go to this link :

http://localhost:3000/users/sign_in 
using <%= link_to "sign in", new_user_session_path %>

Without the line everything is fine, but when the line is present i've got this error :

No route matches {:controller=>"devise/tops", :action=>"show", :id=>10}

What is the connection with this line oO Why it mix devise and tops ? How can this line trouble the route for devise ? Really weird ... besides all my routes seems fine

new_user_session GET   /users/sign_in(.:format)   devise/sessions#new
top GET                /tops/:id(.:format)        tops#show

Upvotes: 1

Views: 100

Answers (1)

citraL
citraL

Reputation: 1156

Please try:

<%= link_to "Official Top", :controller => "/tops", :action => "show", :id => 10 %> 

I think adding the "/" will solve your problem, as it is now searching for the Tops controller within the Devise directory ... with the "/", it will search in the "home controllers" directory instead

Upvotes: 1

Related Questions