Conditional before_safe

How to run before_safe only if a database field contains a certain
value?

I tried:

before_save { |guest| guest.password = md5_pass(guest.password) ,
:if => :enabled? }

def enabled?
self.deleted == 1
end

No success!


Jochen K.
railswerk.de, gissmoh.de, figgfrosch.de, ror-ror.de

That shouldn’t work. I think you are getting before_save confused with
built-in validations. Try it like this:

before_save { |guest| guest.password = md5_pass(guest.password) if
guest.enabled? }

William P. schrieb:

That shouldn’t work. I think you are getting before_save confused with
built-in validations. Try it like this:

before_save { |guest| guest.password = md5_pass(guest.password) if guest.enabled? }

Ok, that’s it! Thanx.


Jochen K.
railswerk.de, gissmoh.de, figgfrosch.de, ror-ror.de