On 20 June 2011 00:19, keith
<keith.tom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> I was looking around a bit and couldn''t find any callbacks that
> executed before before_validation
> The current problem with using before_validation is that it won''t
fire
> if I''m not using validations with #save(:validate => false) -
which
> makes sense. Before_save won''t suffice because I want these
callbacks
> to fire before validation on the occasions that I do use validation.
> Just a sidenote, these callbacks are for normalizing some strings.
>
> Right now, I can do an alias chain on #save and have my sanitization
> methods fire before anything else but I was hoping for something
> cleaner.
I think in that situation I would put the normalization code in
before_save and write the validations so that they pass with the
strings un-normalized, secure in the knowledge that they will be
normalized before saving. This seems aesthetically ok to me as the
purpose of validations is principally to validate user input, and
there is nothing wrong with the user input even though the strings are
not yet normalized.
Colin
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.