borjagvo
borjagvo

Reputation: 2081

How to modify the default behaviour of devise gem in Rails

Devise by default runs resource.save in RegistrationsController#create and not resource.save!. That makes not to raise my resource validations errors. I'm sure they have had thought about this. I took out :validatable from the resource model but it doesn't help.

My question is: doesn't Devise give an option for this?

Upvotes: 0

Views: 45

Answers (1)

rlarcombe
rlarcombe

Reputation: 2986

resource.save! will cause a nasty 500 error if your user model is in an invalid state, whereas resource.save will add the validation errors to the user.errors hash and return false so that the validation errors can be displayed and corrected.

I am therefore not sure why you could prefer save!??

Upvotes: 1

Related Questions