When saving and updating an object, the return value is of boolean type - true
or false
.
As the create
method returns the object as a value, how can I find out if a creation failed or not?
You could try
@object = Blah.create()
@object.persisted? # true or false
also if you want to throw an error instead you could use the bang version, be sure to use rescue
@object = Blah.create!()