我已經看遍了所有地方,並且發現了很多信息...但是對我來說沒有任何作用,我也沒有明白:(覆蓋設計的註冊控制器,以允許在成功完成sign_up後進行重定向
我知道你在想重寫登記控制器,就像這樣:
class Users::RegistrationsController < Devise::RegistrationsController
def after_sign_up_path_for(resource)
authors_waiting_path
end
end
然後繼託尼Amoyal http://www.tonyamoyal.com/2010/07/28/rails-authentication-with-devise-and-cancan-customizing-devise-controllers/顯示的例子中,我應該改變我的路由更新訪問新控制器:
devise_for :users, :controllers => { :registrations => "users/registrations" } do
#get '/author/sign_up', :to => 'devise/registrations#new'
#get '/client/sign_up', :to => 'devise/registrations#new'
get '/author/sign_up', :to => 'users/registrations#new'
get '/client/sign_up', :to => 'users/registrations#new'
end
是的,我在這裏有點奇怪,因爲我正在抓住一些特定的路徑將它們發送到註冊頁面,這使我能夠有效地創建註冊場景。 我評論過我在重寫註冊控制器之前所擁有的。
即使這一切和我authors_waiting_path是一個有效的路徑,它只是不斷在登記:(
這是很無奈後要到登錄頁面。
亞歷
編輯:我也在devise wiki上發現了這個:https://github.com/plataformatec/devise/wiki/How-To:-Redirect-after-registration-(sign-up)
但是我不知道在哪裏定義這個創建方法?我應該重寫會話控制器嗎?
編輯2:
我把控制器的虛擬覆蓋:
class Pouets::RegistrationsController < Devise::RegistrationsController
def after_sign_up_path_for(resource)
authors_waiting_path
end
def new
super
end
def create
puts "was here"
super
end
def edit
super
end
def update
super
end
def destroy
super
end
def cancel
super
end
end
而且我從來沒有在「在這裏」在我的日誌....我真的有一種感覺,它是完全無視越權......我必須做一些錯誤的:(
您使用的是什麼版本的導軌?設計的什麼版本? –
Rails 3.0.3和devise 1.1.5,如果我正確的話,兩者的最後一個版本 – Alex