我正在使用Devise 3.1.1,並試圖在註冊後將用戶重定向到登錄頁面。 作爲Devise's wiki指示我重寫RegistrationsController下列要求:將用戶重定向到登錄頁面註冊後(登記)
class RegistrationsController < Devise::RegistrationsController
protected
def after_inactive_sign_up_path_for(resource)
'/users/sign_in'
end
end
按照指示,我還增加了以下行routes.rb
:
devise_for :users, controllers: { registrations: 'registrations'}
在這之後,我得到以下錯誤,當我轉到登錄頁面:
Invalid route name, already in use: 'new_user_session' You may have defined two routes with the same name using the
:as option, or you may be overriding a route already defined by a resource with the same naming.
在我的路線我已經有這個定義:
devise_for :users, skip: :registrations
devise_scope :user do
resource :registration,
# disabled :edit & :destroy
only: [:new, :create, :update],
path: 'users',
path_names: { new: 'sign_up' },
controller: 'devise/registrations',
as: :user_registration do
get :cancel
end
end
你的路線有兩個'devise_for'塊嗎? –
@JonathanBender yes,'devise_for:users,skip :::registrations'和'devise_for:users,controllers:{registrations:'registrations'}'。我想我需要以某種方式將它們寫出來? – Sbbs