Ha! Rookie error
Thanks for that Fred. :) On Jul 5, 4:52 pm, Frederick Cheung <[email protected]> wrote: > On Jul 5, 11:42 am, Gavin <[email protected]> wrote: > > > module CommonValidations > > > def included(base) > > base.class_eval do > > validates_presence_of :name > > end > > end > > end > > > and then include this module in the models that require it. I've also > > tried various combinations with 'eval' and 'send' etc. > > Did you check to see whether your included method is called at all ? > The included method needs to be a module method, i.e. > > def self.included(base) > ... > end > > for it to be used the way you want it to be used. > > Fred > > > > > The validations aren't called :( > > > Can anyone explain why this isn't working and if it's possbile to re- > > use validations like this? > > > Thanks > > > Gavin > > --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

