2012-06-11 107 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