Using: Rails 3.0.3, Ruby 1.9.2
Here's the relationship:
class Person < ActiveRecord::Base
has_many :contact_methods
accepts_nested_attributes_for :contact_methods
end
class ContactMethod < ActiveRecord::Base
attr_accessible :info
belongs_to :person
end
Now when I try to customize the contact_method labels in I18n, it doesn't recognize it.
en:
helpers:
label:
person[contact_methods_attributes]:
info: 'Custom label here'
I have also tried:
person[contact_method_attributes]
This works just fine for 1-1 relationships, e.g.
person[wife_attributes]:
name: 'My wife'
but not person[wives_attributes]
Thanks in advance
In my Rails 3.2.13 app the attribute labels are picked up automatically from the model whose attributes are embedded. Please note that I am nesting attributes of the belongs_to model, but it might also work the other way around.
My example from working code:
The models:
The view:
translations_de.yml:
And the view is rendered with the subdomain label translated based on
Nice. :)
I'm not sure but it might require you to use the activerecord path instead of the helpers one.
I did this with :
Which is nice but not ideal when you have unlimited options.. I would just specify a custom translation key in the form builder :)
EDIT : Don't know if it's a new feature but seems to work like a charm doing this :