我的主要设计路线是:
devise_for :accounts,:controllers => { :registrations => "users/accounts/registrations",:sessions => "accounts/devise/sessions" },:class_name => 'Admin'
然后我想要一个新的url / action,所以我在上面的devise_for之前添加以下内容:
match '/accounts/signedup/' => 'users/accounts/registrations#signedup':
那么在控制器中我有已注册的动作,但是当我去myurl.com/accounts/signedup目前只有:
def signedup Rails.logger.debug { "&& signed_up" } end
然后我去myurl.com/accounts/signedup我得到:
AbstractController::ActionNotFound (AbstractController::ActionNotFound):
The action 'signedup' could not be found for Users::Accounts::RegistrationsController"
任何想法怎么了?
解决方法
您的答案是正确的,但最近版本的设计已经不赞成这种行为:
Passing a block to devise_for is deprecated. Please remove the block from devise_for (only the block,the call to devise_for must still exist) and call devise_scope :user do … end with the block instead.
根据您发布的内容,在您的情况下,您应该可以在自定义注册控制器中使用after_sign_in_path_for.
以下是我在项目中使用的替代方法:
devise_scope :user do get 'session/on_signin',:to => 'sessions#memorize_session' end