使用事例:
- 管理者はユーザーを作成できる必要があり、ログインを試みてはなりません。
- パブリック ユーザーはアカウントをクレートできます。サインアップ後、すぐにサインインするのではなく、サインイン ページにリダイレクトする必要があります。
誰かがこれで私を助けることができますか?
ありがとう :)
使用事例:
誰かがこれで私を助けることができますか?
ありがとう :)
必要なことは、Devise の RegistrationsController create メソッドをオーバーライドすることです。
ここでそれを行う方法についての優れた説明があります。
これはDeviseの作成アクションです:
# POST /resource
def create
build_resource
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
expire_session_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
respond_with resource
end
end
コントローラーをオーバーライドしたら、削除するだけですsign_in(resource_name, resource)
after_sign_up_path_for(resource)
ニーズに合わせてメソッドを設定することもできます