我正在构建一个使用Devise作为身份验证系统的应用程序。我已经成功覆盖并扩展Devise::RegistrationsController
我自己的Campaigns::RegistrationsController
按预期工作。我曾尝试在Campaigns::DashboardController
处以类似的方式添加一个名为Dashboard的新控制器,但在NoMethodError in Campaigns::Dashboard#show
上获得了<%= devise_error_messages! %>
当我尝试转到网址/dashboard
时。
Campaigns::DashboardController
似乎没有像我的自定义Devise::RegistrationsController
那样继承Campaigns::RegistrationsController
。我不知道为什么会这样。
/routes.rb:
devise_for :campaigns, skip: [:sessions, :registrations, :passwords], controllers: {:omniauth_callbacks: 'omniauth_callbacks', registrations: 'campaigns/registrations', dashboard: 'campaigns/dashboard'}
devise_scope :campaign do
...
match '/account', to: 'campaigns/registrations#edit', via: 'get', as: :edit_campaign_registrations
match '/dashboard', to: 'campaigns/dashboard#show', via: 'get', as: :show_dashboard
end
/campaigns/dashboard_controller.rb:
class Campaigns::DashboardController < Campaigns::RegistrationsController
def show
render :show
end
end
工作/campaigns/registrations_controller.rb继承是:
class Campaigns::RegistrationsController < Devise::RegistrationsController
...
end
我还尝试将我的/campaigns/dashboard_controller.rb编辑为:
class Campaigns::DashboardController < Devise::RegistrationsController
def show
render :show
end
end
因为仪表板不需要我添加的新注册控制器中添加的方法,但无济于事。非常感谢任何帮助。