管理者のみがdeviseで用途を追加できるようにしています。しかし、私は管理者としてログインし、エラーで私を追いかけてくれるサインアップフォームを提出すると、今ほとんどはうまくいきました:http://wiki.summercode.com/rails_authentication_with_devise_and_cancanしかし、このような状況には言及していないようです。管理者がDeviseでユーザーを追加できるようにする
これを許可するには、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
EDIT I:ここで
は私のルート( "編集者" 私のユーザモデルの名前)です私がフォームを提出すると、このProcessing by Devise::RegistrationsController#create as HTML
がログに記録されています。私はおそらくskip_before_filter :require_no_authentication
が呼び出されていないと思われましたが、EditorsController
がRegistrationController
から継承していたので、フィルタが正しく動作する前のものでした。そうじゃないの?
hello Jeremey作成アクションを試しましたが、まだフォームをバイパスして「あなたはすでにサインインしています」というメッセージで私を舐めています。何か案は? – BKSpurgeon