2012-06-11 108 views
1

不好意思,但我找不到我的错误。 这里是我的registrations_controller.rb代码:无法制定设计after_sign_up重定向

class RegistrationsController < Devise::RegistrationsController 
protected 
    def after_sign_up_path_for(resource) 
edit_user_registration_path(current_user) 
end 
end 
在我的路线

devise_for :users, :controllers => { :registrations => "registrations" } 

和重定向是不工作...

回答

1

你试过:

class RegistrationsController < Devise::RegistrationsController 
    protected 

    def after_sign_up_path_for(resource) 
    '/an/example/path' 
    end 
end 

...然后添加到您的路线:

devise_for :users, :controllers => { :registrations => "registrations" } 

所有从this,这需要大约30分钟的搜索谷歌遍历。是唯一为我工作的东西。

编辑: 我也想补充一点,通过代码戳后,它看起来并不像这导致在实际的重定向(不管有些文档说);我得到200回。

0

你的路径应该是有效的(尝试检查rake routes | grep registration),否则你将被重定向到root_path"/"

def signed_in_root_path(resource_or_scope) 
    scope = Devise::Mapping.find_scope!(resource_or_scope) 
    home_path = "#{scope}_root_path" 
    if respond_to?(home_path, true) 
     send(home_path) 
    elsif respond_to?(:root_path) 
     root_path 
    else 
     "/" 
    end 
    end 

from Devise source code