Ruby on rails 如何验证用户身份!工作
我在使用Desive进行登录时遇到问题 所以。。。以下是我的登录操作中发布的内容:Ruby on rails 如何验证用户身份!工作,ruby-on-rails,devise,Ruby On Rails,Devise,我在使用Desive进行登录时遇到问题 所以。。。以下是我的登录操作中发布的内容: Started POST "/sign_in" for 127.0.0.1 at 2011-12-30 17:53:14 +0800 Processing by UsersController#sign_in as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"k/z12JAUDjFaLtw6X+dL5xa7ZtcLKYmxGSc6
Started POST "/sign_in" for 127.0.0.1 at 2011-12-30 17:53:14 +0800
Processing by UsersController#sign_in as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"k/z12JAUDjFaLtw6X+dL5xa7ZtcLKYmxGSc6SAvaFlE=", "user"=>{"email"=>"fivetwentysix@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "x"=>"0", "y"=>"0"}
Completed 401 Unauthorized in 0ms
Processing by UsersController#new as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"k/z12JAUDjFaLtw6X+dL5xa7ZtcLKYmxGSc6SAvaFlE=", "user"=>{"email"=>"fivetwentysix@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "x"=>"0", "y"=>"0"}
Rendered users/new.html.haml within layouts/application (31.7ms)
Completed 200 OK in 40ms (Views: 38.8ms | ActiveRecord: 0.9ms)
这是我试过但不起作用的
def sign_in
authenticate_user!
if signed_in?
redirect_to root_path
else
redirect_to sign_in_path
end
end
所以我想我对Desive的魔法是如何发挥作用的缺乏理解。事情似乎有点太抽象了,以至于我觉得自己与Desive背后的业务逻辑隔绝了,这让我不知所措,因为我不确定如何告诉用户!读取我的参数
所以我的直觉告诉我去查一下你的用户
但这个定义在哪里
我在Deviate的文档中进行了简短的查看,但没有找到其中定义的方法。如果您想在登录/注销后使用自己的重定向或编辑配置文件,如果我理解您的意思,我建议使用这种方法:
class ApplicationController < ActionController::Base
private
def after_sign_out_path_for(resource_or_scope)
root_path
end
def after_sign_in_path_for(resource_or_scope)
root_path
end
def after_update_path_for(resource_or_scope)
root_path
end
end
你到底想替换什么?也许你只是想在登录时添加一些东西,那不是同一个问题。最终,我试图实现一个控制控制器重定向的解决方案。这就是我这么做的全部原因。也许我的方法是完全错误的?无论如何,我将问题的措辞改为更简洁。您是否试图在正常设计工作流程之外手动登录某人?