Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7892507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:53:16+00:00 2026-06-03T06:53:16+00:00

I want to upsert record in database using following command Profile.find_or_create(fname: contact.FirstName, lname: contact.LastName,

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:53:18+00:00Added an answer on June 3, 2026 at 6:53 am

    its find_or_create_by and its deprecated in Rails 3.

    use @foo = Foo.find_by_bar("baz") || Foo.create(:bar => "baz")

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to upsert a document with the mongo-ruby-driver using something like the following-
want to know why String behaves like value type while using ==. String s1
Want make a mind map like the following: Image link is not available anymore.
Want to attach an Event Handler/Listener to some links using the delegate() method, but
Want to know in detail about the purpose of the info Command in redis
I am using a MERGE statement to basically do an UPSERT. For the rows
I have a bit of an upsert type of question... but, I want to
I'm using a map to store a bunch of keys and values. I want
I have a list of strings I want to update in MongoDB using C#
I'm using Mongoid (v3) to access MongoDB, and want to perform this action: db.sessionlogs.update(

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.