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_by
and its deprecated in Rails 3.
use @foo = Foo.find_by_bar("baz") || Foo.create(:bar => "baz")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With