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?
On Apr 23, 3:15 pm, odin <[email protected]> wrote:
> Maybe you should include ValidationHelpers plugin into your model? I
> think, it's not included by default in Sequel::Model.
>
> On Apr 23, 2:22 pm, Kane <[email protected]> wrote:
>
> > In this case, sequel returns exception: in `validate': undefined
> > method `validates_length_range' for #<Post:0xb782a9e4> (NoMethodError)
>
> > On Apr 23, 1:56 pm, odin <[email protected]> wrote:
>
> > > On Apr 23, 1:32 am, Kane <[email protected]> wrote:
>
> > > > I'm trying validate some data in my model using such code
>
> > > > class MyModel < Sequel::Model
> > > > def validates
> > > > validates_length_range 3..5000, :data
> > > > end
> > > > end
>
> > > > But if putting wrong values no exception raises
>
> > > > model = MyModel.create(:data => 'f')
> > > > puts model.valid? #=> true
>
> > > > Deprecated method Sequel::Model.validates_length_of works fine… What
> > > > i should use for validations in Sequel 2.12?
>
> > > > Artem
>
> > > Validation method should be named "validate", not "validates" as in
> > > your code
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---