Ok this seems to work for seeds.
Now I am trying to authenticate the user through facebook. I get this
error:
NoMethodError in Devise/oauth callbacksController#facebook
undefined method `persisted?' for true:TrueClass
In my user model, I have:
def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
data = ActiveSupport::JSON.decode(access_token.get('https://
graph.facebook.com/me?'))
if user = User.find_by_email(data['email'])
user
else
# Create an user with a stub password.
user = User.new(
:email => data['email'],
:first_name => data['first_name'],
:last_name => data['last_name'],
:password => 'password123',
:password_confirmation => 'password123'
)
user.skip_confirmation!
user.save!
end
end
However, with the following code below, everything seems to work...
Why is this error coming up?
Arent both methods the same?
def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
data = ActiveSupport::JSON.decode(access_token.get('https://
graph.facebook.com/me?'))
if user = User.find_by_email(data['email'])
user
else
# Create an user with a stub password.
user = User.create!(
:email => data['email'],
:first_name => data['first_name'],
:last_name => data['last_name'],
:password => 'password123',
:password_confirmation => 'password123'
)
end
end
On Sep 28, 7:03 am, Carlos Antonio da Silva