In Rails 2 if I wanted to check if an ActiveRecord attribute had an
error on it I simply called

    assert user.errors.on(:name)

Now that this is depreciated what is a clean way to do this check?

This is ugly but it works..
    assert !user.errors[:name].empty?

remove the negative logic and it is still a bit verbose
    assert user.errors[:name].first

Stealing from the old on method we could use has_key?
   assert user.errors.has_key?(:name)

I suspect a lot of people accidentally change their validations to
   assert user.errors[:name]
but that always returns true

anyway,  what is the preferred way to do this check?   I feel like I'm
missing something obvious.  :-)

Tony

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

Reply via email to