Ruby on Rails Thursday, February 1, 2018

On Wed, Jan 31, 2018 at 11:30 PM, fugee ohu <fugee279@gmail.com> wrote:
> I'm having find_or_create_by roll back on me in the console directly from
> the model I'm not providing an id, the mysql id column is autoincrement
> Model.find_or_create_by(person_id: 1, picture_id:37)

Aside from what other people have already pointed out --

Model.find_or_create_by! will raise an exception on failure, which

will give you more direct info.

I highly recommend reading the docs.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yAR8n5XFzmtPO%3Dx5Grq6gNeEQVa2EzYoE9h511Vqfr9sQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment