简体   繁体   中英

Where are Default Validation Error Messages in Rails 3.0?

Where are the default validation error messages in Rails 3.0? What is the equivalent of ActiveRecord::Error.default_error_messages[:taken], for example? I have gotten as far as finding that ActiveModel handles the errors rather than ActiveRecord, but I can't find the errors themselves.

http://github.com/rails/rails/blob/master/activemodel/lib/active_model/locale/en.yml

and

http://github.com/rails/rails/blob/master/activerecord/lib/active_record/locale/en.yml

:D

UPDATE:

Maybe you should try to add your own custom error messages?

# de.yml
activerecord:
  errors:
    messages:
      taken: "ist bereits vergeben"

# test_spec.rb
...
assert_equal(object.errors[field], I18n.t("activerecord.errors.messages.taken"))
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM