Ruby on Rails Sunday, May 2, 2010

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..

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment