Hi all,
I have several models which all have an email field. This email address
should of course be validated and for that I have this nice regex. But
now I have the email validation method copied throughout my different
models. Which is clearly stupid. I figured I needed a helper (module?)
and use this helper I my models. But I can’t seem to find anyway of
helpers for models, only for the controllers and views. Am I missing
something here?
Any help is greatly appreciated.
Hi all,
I have several models which all have an email field. This email address
should of course be validated and for that I have this nice regex. But
now I have the email validation method copied throughout my different
models. Which is clearly stupid. I figured I needed a helper (module?)
and use this helper I my models. But I can’t seem to find anyway of
helpers for models, only for the controllers and views. Am I missing
something here?
Any help is greatly appreciated.
Harm
I’ve put mine in environment.rb as a constant and then just refer to in
in my model validation.
On Sat, 11 Mar 2006 13:32:41 +0100, Anthony G. wrote:
Harm aa wrote:
But I can’t seem to find anyway of
helpers for models, only for the controllers and views. Am I missing
something here?
Any help is greatly appreciated.
I’ve put mine in environment.rb as a constant and then just refer to in
in my model validation.
For more complicated cases, there are two ways to do it: inherit your
models from a common class, or put your helper functions into a mixin.
See: