创建一个自定义设计控制器,在用户登录后将其重定向到您想要的位置:
创建自定义控制器: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_for :users, :controllers => {:sessions => "users/sessions"}