ruby-on-rails – 添加新操作来设计registrations_controller

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 添加新操作来设计registrations_controller前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的主要设计路线是:
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):

但是如果我从控制器中删除了def的注册表,我可以得到:

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
原文链接:https://www.f2er.com/ruby/273091.html

猜你在找的Ruby相关文章