在/ users / sign_in设计参数错误

时间:2014-03-10 00:38:33

标签: ruby-on-rails-4 devise

我正在从Rails教程和Railscasts身份验证系统从头开始切换到Devise。到目前为止,我已经完成了所有设置,包括安装,配置,创建用户模型和清理旧系统(会话控制器,路由修改等)。

提交sign_up表单时出现错误

  

/ users / sign_in中的ArgumentError参数数量错误(2为1)

在档案

createdevise (3.2.3) app/controllers/devise/sessions_controller.rb

def create
    self.resource = warden.authenticate!(auth_options)
    set_flash_message(:notice, :signed_in) if is_flashing_format?
    sign_in(resource_name, resource)
    yield resource if block_given?
    respond_with resource, :location => after_sign_in_path_for(resource)
end

sign_in(resource_name,resource)行发生错误。在我的better_errors调试屏幕中,如果我键入resource_name,则返回:user,如果我键入resource,则返回

#<User id: 5, email: "firstname.lastname@example.com", created_at: "2014-03-09 23:20:41", updated_at: "2014-03-10 00:24:02", password_digest: nil, remember_token: "s2BEo5V123ysJ8phH48C", first_name: "firstname", last_name: "lastname", encrypted_password: "$2a$10$KPUF1BQ9RCLRSA4z5vDBIeN...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: "2014-03-09 23:37:06", sign_in_count: 5, current_sign_in_at: "2014-03-10 00:24:02", last_sign_in_at: "2014-03-10 00:01:15", current_sign_in_ip: "1.2.3.4", last_sign_in_ip: "1.2.3.4", failed_attempts: 0, unlock_token: nil, locked_at: nil>

我试图理解我在设置中做错了什么以及sign_in方法需要什么参数。错误是说只有一个参数,我提供了2个,但sign_in帮助器看起来需要2个。

我有没有办法解决这个问题,因为它在设计源代码中?我可以在用户模型或控制器中修复它吗?

我的服务器输出是:

    Started POST "/users/sign_in" for 172.17.42.1 at 2014-03-
10 00:24:02 +0000                                        
Processing by Devise::SessionsController#create as HTML  
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"i+lOVq
0/H9mEhvs+Oxp0MWY123p7kWPe2Ef+jOv/L88=", "user"=>{"email"
=>"firstname.lastname@example.com", "password"=>"[FILTERED]", "
remember_me"=>"0"}, "commit"=>"Sign in"}                 
  User Load (2.2ms)  SELECT "users".* FROM "users" WHERE 
"users"."email" = 'firstname.lastname@example.com' ORDER BY "us
ers"."id" ASC LIMIT 1                                    
   (0.3ms)  BEGIN                                        
  SQL (8.1ms)  UPDATE "users" SET "last_sign_in_at" = $1,
 "current_sign_in_at" = $2, "sign_in_count" = $3, "update
d_at" = $4 WHERE "users"."id" = 5  [["last_sign_in_at", M
on, 10 Mar 2014 00:01:15 UTC +00:00], ["current_sign_in_a
t", Mon, 10 Mar 2014 00:24:02 UTC +00:00], ["sign_in_coun
t", 5], ["updated_at", Mon, 10 Mar 2014 00:24:02 UTC +00:
00]]                                                     
   (2.3ms)  COMMIT                                       
Completed 500 Internal Server Error in 167ms             

ArgumentError - wrong number of arguments (2 for 1):     
  devise (3.2.3) app/controllers/devise/sessions_controll
er.rb:17:in `create'    

挣扎着找到正确的方式提出这个问题所以任何想法都会受到赞赏。

0 个答案:

没有答案