Forum: Ruby on Rails ActiveRecord::Errors best practices?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Joachim G. (Guest)
on 2009-04-27 15:05
I'm currently reviewing some old code from Rails 1.x times and found
this:

  ActiveRecord::Errors.default_error_messages = {
    :inclusion => "inclusion|",
    :exclusion => "exclusion|",
    :invalid => "invalid|",
    :confirmation => "confirmation|",
    :accepted => "accepted|",
    :empty => "empty|",
    :too_long => "too_long|",
    :too_short => "too_short|",
    :wrong_length => "wrong_length|",
    :taken => "taken|",
    :not_a_number => "not_a_number|",
  }

Used on controller code to check if a specific error happens, like this:

if @user.errors.on("email").to_s.include? "taken|"
  ...
end

Are there better practices for doing this?
This topic is locked and can not be replied to.