internationalization - Rails 4 I18n: Using human model name in association validation message -
i have simple object like:
class question < activerecord::base belongs_to :company validates :company, presence: true end and can't i18n of validation message utilize human model name error message.
i have stored key "activerecord.models.company" "firma" (german), , when company.model_name.human, returns "firma", expected. still appears "company" in error message, until store "activerecord.attributes.question.company".
this annoying, because need add together attribute key every model validates association company (i.e. "activerecord.attributes.user.company", "activerecord.attributes.project.company").
is there way reference human model name instead of attribute?
i think that's because in form, companies's fields depend on "has_many" relation, through fields_for helper, using "accepts_nested_attributes" in model:
i supose have...
in form
<%= question.fields_for companies |c| %> ... in model
class question<activerecord::base has_many :companies accepts_nested_attributes_for :companies, :allow_destroy => :true ...
i think (until now) normal...because companies of "questions" can have 1 name, , companies of "projects" can have one, , on
ruby-on-rails-4 internationalization associations
No comments:
Post a Comment