I have a use case where I have an STI with the setup below:
class BudgetLine::Accommodation < BudgetLine
has_many :budget_line_items
accepts_nested_attributes_for :budget_line_items
end
In a form for BudgetLine::Accommodation
, I have a nested form for BudgetLineItem
, where I need the labels for the attributes to be unique for that model; different than e.g. BudgetLine::Transportation
etc.
In this part of the Rails Internationalization documentation it states:
"In the event you need to access nested attributes within a given model, you should nest these under model/attribute
at the model level of your translation file:
en:
activerecord:
attributes:
user/role:
admin: "Admin"
contributor: "Contributor"
I thought this applied to my case, but I can’t get it to work with.
en:
activerecord:
attributes:
budget_line:
accommodation/budget_line_item:
unit: Room
Can anyone explain to me what exactly is meant here? Is this just another way to structure namespaced models and doesn’t apply to nested attributes for forms?