在向Devise添加新Controller后获取NoMethodError

时间:2014-04-10 16:29:17

标签: ruby-on-rails-4 devise controllers

我正在构建一个使用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

因为仪表板不需要我添加的新注册控制器中添加的方法,但无济于事。非常感谢任何帮助。

0 个答案:

没有答案