奇怪的路线故障,设计和自己的控制器之间的混合 [英] Weird route malfunction, mix between devise and own controller
问题描述
这里是(在application.html.erb中)有问题的行:
<%= link_toOfficial Top,:controller => tops,:action => show,:id => 10%>
当我想使用devise登录时,当我进入此链接时,会出现问题: p>
http:// localhost:3000 / users / sign_in
使用<%= link_to登录,new_user_session_path% >
没有这一行,一切都很好,但是当行存在时,我有这个错误: / p>
没有路由匹配{:controller =>devise / tops,:action =>show,:id = > 10}
与这条线的连接是什么oO为什么混合设计和顶部?这条线怎么会麻烦设计的路线?真的很奇怪...除了所有的路线似乎很好
new_user_session GET /users/sign_in(.:format)devise / sessions#新
顶部GET /tops/:id(.:format)tops#show
请尝试:
<%= link_toOfficial Top,:controller => ; / tops,:action => show,:id => 10%>
我认为添加/可以解决您的问题,因为它正在搜索Tops控制器在Devise目录下,使用/,它将在家庭控制器目录中搜索
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
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
这篇关于奇怪的路线故障,设计和自己的控制器之间的混合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!