views:

9

answers:

0

Given:

class Foo
    include DataMapper::Resource

    property :title, String, :length => 255

    validates_length :title, :in => (50..255), :allow_nil => false, :when => :long_title
    validates_length :title, :in => (5..50),   :allow_nil => false, :when => :short_title
end

When I run:

my_foo.valid? :long_title

I get:

ArgumentError: validation context long_title doesn't seem to be defined. Known contexts are [:short_title]

When I run:

my_foo.valid? :short_title

I get:

ArgumentError: validation context long_title doesn't seem to be defined. Known contexts are [:long_title]

When I run:

my_foo.valid? :doesnt_exist

I get:

ArgumentError: validation context long_title doesn't seem to be defined. Known contexts are [:long_title, :short_title]

What gives? I'm completely at a loss as to what is going on here.