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