设计:新的用户注册问题,PG :: ProtocolViolation。 Rails4,Postgres

时间:2013-11-12 07:02:15

标签: ruby-on-rails activerecord devise omniauth rails-postgresql

我正在使用devise和omni-auth登录linkedin。

我将from_omniauth方法添加到Railscast中提到的用户模型:

这是代码:

#Create a new user if does not exist   
def self.from_omniauth(auth)
    where(auth.slice(:provider, :uid)).first_or_create! do |user|
       user.provider = auth.provider
       user.uid = auth.uid
       user.email = auth.info.email
    end
end


Started GET "/users/auth/linkedin/callback?oauth_token=XXX" 
INFO -- omniauth: (linkedin) Callback phase initiated.
Processing by OmniauthCallbacksController#linkedin as HTML

   (0.4ms)  BEGIN
  User Exists (0.6ms)  SELECT 1 AS one FROM "users" WHERE "users"."email" = 'email@yahoo.com' LIMIT 1
  SQL (3.6ms)  INSERT INTO "users" ("created_at", "email", "provider", "uid", "updated_at") VALUES ('2013-11-12 06:50:57.811205', 'email@yahoo.com', 'linkedin', 'XXXX', '2013-11-12 06:50:57.811205') RETURNING "id"  *[["created_at", Tue, 12 Nov 2013 06:50:57 UTC +00:00], ["email", "email@yahoo.com"], ["provider", "linkedin"], ["uid", "XXXX"], ["updated_at", Tue, 12 Nov 2013 06:50:57 UTC +00:00]]*
**PG::ProtocolViolation: ERROR:  bind message supplies 5 parameters, but prepared statement "a1" requires 0**
: INSERT INTO "users" ("created_at", "email", "provider", "uid", "updated_at") VALUES ('2013-11-12 06:50:57.811205', 'pavan_2k6@yahoo.com', 'linkedin', 'ts2xg5e6d9', '2013-11-12 06:50:57.811205') RETURNING "id"
   (0.3ms)  ROLLBACK
Completed 500 Internal Server Error in 117ms

PG::ProtocolViolation - ERROR:  bind message supplies 5 parameters, but prepared statement "a1" requires 0

我很难弄清楚为什么没有生成正确的查询。如果我复制插入语句并运行它..记录将被插入数据库中。但它在上面的查询中返回Id ..之后生成那些额外的参数。

知道如何解决这个问题吗?

由于

0 个答案:

没有答案