Create! method_missing?

So, all the documentation says I should be able to call #create! on an
ActiveRecord, to do the same thing as #create, but raise an exception on
validation failure.

But when I try this on any ActiveRecord::Base class, I seem to get an
exception raised with method_missing, saying there’s no create! method.

Am I missing something?

Jonathan R. wrote:

So, all the documentation says I should be able to call #create! on an
ActiveRecord, to do the same thing as #create, but raise an exception on
validation failure.

But when I try this on any ActiveRecord::Base class, I seem to get an
exception raised with method_missing, saying there’s no create! method.

Am I missing something?

Hey,

I have always used #save instead of #save!, and still can catch those
validation errors!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs