I want to upsert record in database using following command
Profile.find_or_create(fname: contact.FirstName, lname: contact.LastName,
company: account.Name, title: contact.Title, user_id: contact.CreatedById,
account_id: account.Id, contact_id: contact.Id, type: "contact" )
where Profile is an activerecord model
but I get following error
undefined method find_or_create for Profile class
Profile.public_methods doesn’t show find_or_create method but Activerecord Api defines the above method.
What might be wrong?
its
find_or_create_byand its deprecated in Rails 3.use
@foo = Foo.find_by_bar("baz") || Foo.create(:bar => "baz")