如何修复破坏的路线路线1.0.4 [英] How to fix broken devise routing under journey 1.0.4

查看:175
本文介绍了如何修复破坏的路线路线1.0.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在这个SO问题中解决我的突然断路问题:
Devise / users / sign_in重定向到错误的控制器,并帮助我将问题与从更新到rails 3.2时发生的1.0.3到1.0.4之间的升级隔离开来。 7。

I began troubleshooting my "sudden" broken routes problem in this SO question: Devise /users/sign_in redirecting to wrong controller and with help I was able to isolate the issue to the upgrade from journey 1.0.3 to 1.0.4 that occurred when I updated to rails 3.2.7.

如你所知,我们需要在rails 3.2.8中应用重要的安全修复程序,但这意味着我必须使用1.0.4的行程,我的设计路线。例如,我的自定义new_user_session路由是受欢迎的#欢迎,但它被解码设计/欢迎#欢迎不存在。

As you know, we need to be at rails 3.2.8, to apply important security fixes, but this means I must use journey 1.0.4, which breaks my devise routes. For instance, my custom new_user_session route is welcome#welcome, but it is being decoded to devise/welcome#welcome which does not exist.

有人遇到这种爱三角形,如果是这样,你是如何使用1.0.4玩的很好的设计?

Has anybody else run into this love triangle, and if so how did you make journey 1.0.4 play nice with devise?

破坏的路由(根和设计路径:

The routes that are broken (root and devise routs:

    devise_for :users   
    devise_scope :user do
       get "/login"    => "devise/sessions#new"
       get "/register" => "devise/registrations#new"
    end  
    match '/signout/confirm' => 'signouts#confirm'

    root :to => "welcome#welcome"

=========== ================================================== ===

================================================================

编辑:2012-09-05

2012-09-05

解决方案:

我发现违规的LOC:

link_to_unless_current( logo_image, { :controller => 'welcome', :action => 'welcome' } )

我将其更改为:

link_to_unless_current( logo_image, { :controller => '/welcome', :action => 'welcome' } )

无效。

出于好奇,我改为:

link_to( logo_image, { :controller => '/welcome', :action => 'welcome' } )

>

and that worked, as did:

link_to( logo_image, { :controller => 'welcome', :action => 'welcome' } )

所以我尝试的最后一件事是:

So the last thing I tried was:

link_to_unless_current( logo_image, root_path )

哪些工作,宇宙。

POSTMORTEM:
我没有经验的rails文档导致我推断,虽然 link_to()将接受root_path作为参数, link_to_unless_current()不会。直到我看到方法的源代码,我发现(并且应该一直假设), link_to_unless_current()建立在 link_to_unless(),反过来建立在 link_to()之上。

POSTMORTEM: My inexperience with the rails documentation led me to infer that while link_to() would accept root_path as a parameter, that link_to_unless_current() would not. It wasn't until I looked at the source code for the methods, that I found (and should have assumed all along) that link_to_unless_current() is built on top of link_to_unless(), which in turn is built on top of link_to().

Big 谢谢给在线程和前一个帮助的人。

Big Thank You to the folks who helped out in this thread and the previous one.

推荐答案

我的旅程1.0.4和我的小Rails学习项目中有一个类似的问题,其中加载设计注册页面失败,路由错误。我可以通过更改通过views / layouts / application.html.erb及其部分添加到站点头部的链接来解决问题。

I had a similar problem with journey 1.0.4 and devise in my little Rails learning project, where loading the devise sign-up page failed with a routing error. I was able to fix the problem by changing the links that were added to the site's header by views/layouts/application.html.erb and its partials.

我更改了链接像这样:

<%= link_to 'Home', {:controller=>'welcome', :action=>'index'} %>

to:

<%= link_to 'Home', {:controller=>'/welcome', :action=>'index'} %>

路由开始工作。

这篇关于如何修复破坏的路线路线1.0.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆