ユーザーがログインすると、ユーザーを目的の場所にリダイレクトするカスタム デバイス コントローラーを作成します。
カスタムコントローラーを作成します: controllers/users/sessions_controller.rb
class Users::SessionsController < Devise::SessionsController
before_filter :authenticate_user!, :only => [:destroy]
def new
super
end
def create
#Can edit this for custom redirect
super
end
def destroy
super
end
protected
def stub_options(resource)
methods = resource_class.authentication_keys.dup
methods = methods.keys if methods.is_a?(Hash)
methods << :password if resource.respond_to?(:password)
{ :methods => methods, :only => [:password] }
end
def after_sign_in_path_for(resource)
#Can edit this for custom redirect
super
end
def after_sign_out_path_for(resource)
super
end
private
end
次に、routes.rb でそのコントローラーを使用するように devise に指示します。
devise_for :users, :controllers => {:sessions => "users/sessions"}