Having trouble with Validatable

I need to use the level option for my app, so I did ‘gem install
validatable’

Next I got an error when it tried to run, so after some searching,
'require ‘validatable’ in environment.rb

Now it says ‘Unknown key(s): level’ when a view tries to render a
partial from that model…

class Person < ActiveRecord::Base
include Validatable
belongs_to :household

validates_numericality_of :month_int, :level => 1
validates_numericality_of :day_int, :level => 1
validates_numericality_of :year_int, :level => 1
validates_presence_of :sex, :m, :d, :y
validates_length_of :sex, :is => 1
validates_date :birthday, :after => Date.new(1900, 1, 1), :before =>
Proc.new { 1.day.from_now.to_date }, :before_message => ‘Ensure it is
before %s’, :after_message => ‘Ensure it is after %s’, :level => 2
before_validation do

debugger

self.month_int = self.m.to_i
self.day_int = self.d.to_i
self.year_int = self.y.to_i

end
after_validation do
debugger
self.birthday = Date.new(self.year_int, self.month_int,
self.day_int)
end
end

Please help…

Hi,
You just add include Validatable in your model after installing
validatable gem. level option will work with active record validation.
For more information refer this url - http://validatable.rubyforge.org/

I think that’s what I did. I know the gem is running because I had
validates_numericality using minimum and maximum, which broke as soon
as I installed the gem. Validatable doesn’t have those options. The
include is on line 2 of the model.

Bob

On May 4, 5:27 am, Bob S. [email protected] wrote:

I think that’s what I did. I know the gem is running because I had
validates_numericality using minimum and maximum, which broke as soon
as I installed the gem. Validatable doesn’t have those options. The
include is on line 2 of the model.

Can you isolate which validation is causing the issue ? just looking
at the docs for validatable, looks like it might not have a
validates_date method - you’re picking up the Active Record
validates_date which of course doesn’t expect a :level option

Fred