牌語備忘録 -pygo

あくまでもメモです。なるべくオフィシャルの情報を参照してください。

牌語備忘録 -pygo

Rails3 の 認証プラグイン devise で サイインイン・アウト後のリダイレクト先を指定する件

やりたい時に忘れるからメモ

サインアウト後のリダイレクト先を指定

How To: Change the redirect path after destroying a session i.e. signing out · plataformatec/devise Wiki · GitHub

for exsample

app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  private

  # Overwriting the sign_out redirect path method
  def after_sign_out_path_for(resource_or_scope)
    root_path
  end
end

サインイン後のリダイレクト先を指定

How To: redirect to a specific page on successful sign in · plataformatec/devise Wiki · GitHub

for exsample

app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  protect_from_forgery

  def after_sign_in_path_for(resource)
    admin_path
  end
end