我正在努力做到这一点,因此只有管理员才能通过设计添加用途。我已经让它大部分工作了,但是现在当我以管理员身份登录并提交注册表单时,它把我踢回来并出现错误:You are already signed in.
我尝试按照此处的说明进行操作:http ://wiki.summercode.com/rails_authentication_with_devise_and_cancan但似乎没有提到这种情况。
我是否需要进一步覆盖editors_controller
以允许这样做?
这是我的路线(“编辑器”是我的用户模型的名称):
devise_for :admins, :skip => [:registrations]
as :admin do
get 'admin/editors' => 'editors#index', as: :admin_editors
get 'admin/editors/new' => 'editors#new', as: :new_editor
delete 'admin/editors/:id' => 'editors#destroy', as: :destroy_editor
end
devise_for :editors, :skip => [:registrations], :controllers => { :registrations => "editors" }
和我editors_controller
的“应用程序/控制器/”
class EditorsController < Devise::RegistrationsController
before_filter :check_permissions, :only => [:new, :create, :cancel]
skip_before_filter :require_no_authentication
def dashboard
render "editors/dashboard.html.haml"
end
def index
@editors = Editor.all
respond_to do |format|
format.html
end
end
private
def check_permissions
authorize! :create, resource
end
end
编辑Processing by Devise::RegistrationsController#create as HTML
当我提交表单时,我在日志中
注意到了这一点。我曾怀疑可能skip_before_filter :require_no_authentication
没有被调用,但假设因为EditorsController
继承自RegistrationController
过滤器之前的过滤器会正常工作。不是这样吗?