Yeah, I ran into this too. DataMapper::Validate doesn't work very well on its own right.
My retarded solution... use DataMapper::Resource and just create the tables but don't use them (call valid? but not save). Someone has to have a better solution than this though. Anyone? On Oct 9, 2009, at 3:21 AM, Ashley Moran wrote: > > > On Oct 04, 2009, at 11:44 am, Jacques Crocker wrote: > >> ----- >> Using just validate (works, kindof): >> >> class Employer >> include DataMapper::Validate >> >> attr_accessor :name >> attr_accessor :company >> validates_present :name >> >> end >> >> >> This is what I ended up using, however it sucks since I don't have >> access to the Datamapper builder methods (attributes= etc). So I have >> to assign each accessory manually. We should think about making these >> datamapper accessors methods a module so people can include them ala >> cart > > > Coincidentally, I'm also trying to use validations on their own right > now. `validates_present` works, but `validates_is_confirmed` fails > with > > undefined method `model' for #<Signups::SignupForm:0x104460758> > > > The culprit is here: > > if target.model.properties.named?(field_name) > return true unless target.attribute_dirty?(field_name) > end > > At first glance, this seems excessive dependency on Resource. Is it > fair that Validations depends on Resource? I had imagined they would > be (or could be) independent. > > Cheers > Ashley > > -- > http://www.patchspace.co.uk/ > http://www.linkedin.com/in/ashleymoran > http://aviewfromafar.net/ > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" 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/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
