# Having trouble with Validatable

**URL:** <https://www.ruby-forum.com/t/having-trouble-with-validatable/187951>\
**Category:** Rails\
**Created:** [May 3, 2010, 7:53am UTC](https://www.ruby-forum.com/t/having-trouble-with-validatable/187951 "2010-05-03T07:53:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [May 3, 2010, 7:53am UTC](https://www.ruby-forum.com/t/having-trouble-with-validatable/187951/1 "2010-05-03T07:53:27Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [May 3, 2010, 12:53pm UTC](https://www.ruby-forum.com/t/having-trouble-with-validatable/187951/2 "2010-05-03T12:53:47Z")

</div>

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/](http://validatable.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [May 4, 2010, 6:28am UTC](https://www.ruby-forum.com/t/having-trouble-with-validatable/187951/3 "2010-05-04T06:28:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [May 4, 2010, 12:57pm UTC](https://www.ruby-forum.com/t/having-trouble-with-validatable/187951/4 "2010-05-04T12:57:08Z")

</div>

On May 4, 5:27 am, Bob S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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
