What if i need to do some extended checking, which of course require
direct acces to the db field, what should i do?

On Apr 23, 7:45 pm, Jeremy Evans <[email protected]> wrote:
> On Apr 23, 5:23 am, Kane <[email protected]> wrote:
>
>
>
> > Yes, plugin wasn't included
> > This code works, but the way the whole thing works isn't obvious for
> > me…
>
> > require 'sequel'
> > require 'sequel/plugins/validation_helpers'
>
> > class MyModel < Sequel::Model
> >   include  Sequel::Plugins::ValidationHelpers::InstanceMethods
> >   def validates
> >     validates_length_range 3..5000, :data
> >   end
> > end
>
> > Why ValidationHelpers module have not any methods and i should include
> > InstanceMethods?
>
> You are supposed to use it with Model.plugin:
>
>   class MyModel < Sequel::Model
>     plugin :validation_helpers
>
>     def validate
>       super
>       validates_length_range 3..5000, :data
>     end
>   end
>
> In most cases where validation is desired, you want it on all of your
> models, so you'd do:
>
>   Sequel::Model.plugin :validation_helpers
>
> after requiring sequel.  Then you don't have to add the plugin in
> every model class.
>
> Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-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/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to