i try to create a custom getOrCreate method using find and if nothing is returned using create
my class :
class User
include Neo4j::ActiveNode
include Neo4jrbConcern
property :name
property :email
validates :name, :presence => true
validates :email, :presence => true
end
the method getOrCreate inherited from the concern
def getOrCreate(params)
obj = self.find(params)
if obj
puts 'obj found : ' + obj
return obj
else
return self.create(params)
end
end
i'm trying this :
User.getOrCreate(
name: data['name'],
email: data['email']
)
the result is this error :
Neo4j::Session::CypherError: uuid not defined (line 1, column 86)
"MATCH (result_user:`User`) WHERE result_user.uuid.name = {result_user_uuid_name} AND uuid.email = {result_user_uuid_email} RETURN result_user ORDER BY ID(result_user) LIMIT {limit_1}"
^
/Users/xxx/.rvm/gems/ruby-2.1.5/gems/neo4j-core-4.0.0/lib/neo4j-server/cypher_response.rb:166:in `raise_cypher_error'
/Users/xxx/.rvm/gems/ruby-2.1.5/gems/neo4j-core-4.0.0/lib/neo4j-core/query.rb:164:in `response'
/Users/xxx/.rvm/gems/ruby-2.1.5/gems/neo4j-core-4.0.0/lib/neo4j-core/query.rb:205:in `pluck'
do you see what i did wrong ?
thanks !
Benoît