问题
I am using devise and omni-auth to login with linkedin .
I added the from_omniauth method to user model as mentioned in the Railscast:
This is the code:
#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', 'XXXX@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
I am having a hard time figuring out why a correct query is not generated. If I copy the insert statement and run it ..the record gets inserted in the db fine. But its generating those extra parameters after returning Id .. in the query above.
Any idea how to resolve this ?
Thanks
来源:https://stackoverflow.com/questions/19922887/devise-new-user-registration-issues-pgprotocolviolation-rails4-postgres