Rails 3 ActiveModel Nested Class I18n
Posted
by Dave
on Stack Overflow
See other posts from Stack Overflow
or by Dave
Published on 2010-05-15T16:22:57Z
Indexed on
2010/05/16
5:00 UTC
Read the original article
Hit count: 235
Given the following class definition in ruby:
class Conversation
class Message
include ActiveModel::Validations
attr_accessor :quantity
validates :quantity, :presence => true
end
end
How can you use i18n to customize to error message. For example the correct lookup for the class Conversation would be
activemodel:
errors:
models:
conversation:
attributes:
quantity:
blank: "Some custom message"
But what is it for the Message class? I tried:
activemodel:
errors:
models:
conversation:
message:
attributes:
quantity:
blank: "Some custom message"
activemodel:
errors:
models:
message:
attributes:
quantity:
blank: "Some custom message"
activemodel:
errors:
models:
conversation::message:
attributes:
quantity:
blank: "Some custom message"
None of them work Any ideas or is this a bug with ActiveModel or I18n?
© Stack Overflow or respective owner