我正在使用 Devise 3.1.1 并尝试在用户注册后将其重定向到登录页面。按照设计的 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
:作为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