This is a fresh test with the 3.0.2 but preceding version had the same behavior.
class UserIdentity
include Neo4j::ActiveNode
def self.from_omniauth(auth)
if email = auth.info.email.nil?
email = Devise.friendly_token[0,5] + "@" + Devise.friendly_token[0,5] + "." + Devise.friendly_token[0,3]
end
puts "provider: #{auth.provider} - uid: #{auth.uid} - email: #{email}"
identity = UserIdentity.find_by(provider: auth.provider, uid: auth.uid)
puts "identity has been found: #{identity.class} - #{identity}"
if identity.class == nil.NilClass
identity = UserIdentity.create(provider: auth.provider, uid: auth.uid, email: email, password: Devise.friendly_token[0,20])
puts "identity should have been created: #{identity.class} - #{identity}"
end
end
As I'm running on an empty DB, the result of the find_by should be obviously 'nil'. It returns nil:NilClass or NilClass
Below, you can find the returning error:
provider: twitter - uid: 11125452 - email: AS...@jKcZz.tbM
CYPHER 4ms MATCH (n:`UserIdentity`) WHERE n.provider = {n_provider} AND n.uid = {n_uid} RETURN n LIMIT 1 | {:n_provider=>"twitter", :n_uid=>"11125452"}
identity has been found: NilClass -
Completed 500 Internal Server Error in 5ms
NoMethodError (undefined method `NilClass' for nil:NilClass):
app/models/user_identity.rb:108:in `from_omniauth'
app/controllers/user_identities/omniauth_callbacks_controller.rb:33:in `set_auth'
app/controllers/user_identities/omniauth_callbacks_controller.rb:8:in `twitter'