Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Rails 3.1 nested I18n namespace deprecations #1869
Working off of 3-1-stable branch I'm getting lots of the following deprecation warnings:
[DEPRECATION WARNING] Nested I18n namespace lookup under "activerecord.attributes.order" is no longer supported ... [DEPRECATION WARNING] Nested I18n namespace lookup under "activerecord.models.order" is no longer supported
After digging through the code I can't seem to find any suggested or replacement structure.
Here's the current yml that's causing the warnings:
en: activerecord: attributes: order: ship_address: address1: "Shipping address street" state: State total: Total models: order: one: Order other: Orders
I'm happy to submit a patch for deprecation warning once I know how to replace the existing values.
According to @josevalim so-called "nested models" (ie.
Okay, so the first instance has been fixed recently (thank you), but the second is still an issue.
From the yaml above, if I remove the nested ship_address values the validation messages on an order update (with nested attributes for the ship_address association) would look like:
"Ship address address1 can't be blank"
instead of the current:
"Shipping address street can't be blank"
So will it be possible to localize associations anymore when the nested lookup is actually removed?
I just got the same deprecation when working with nested forms. If this function is removed, I don't really see a working solution for now, is that correct?
On the other hand, the current situation wasn't very DRY anyway, as you had to repeat the same attribute name for each nested form.
@JeanMertz: The situation with nested forms could be made DRY with YAML aliases:
foo: &foo_atts bar: "Bar!" baz: "Arrrr!!" snafu: <<: *foo_atts
This way, you'd have a
activerecord: attributes: address: &address_attributes name: "Full name" zip: "Zip code" user: email: "Mail address" address_fields: <<: *address_attributes
But that causes deprecation warnings now...
Have any workarounds been developed since July?
@dmke thanks, that certainly cleans things up, but if that also shows the deprecation then I guess we still don't have a viable alternative.
I don't understand how something can be deprecated if there is no clear alternative? I mean, surely there must be plenty of users serving international Rails apps to their customers? But looking at the number of replies here it's almost as if it's a non-issue (I guess it is, as it's only a deprecation warning, but who knows, perhaps the feature will be completely removed in 3.2)
I've got the same problem. I've got
activerecord: attributes: web/account: password_digest: "Password"
But I have no idea how to create translations for the nested form where I edit user and his web account.
activerecord: attributes: user: web_account: password: "Password"
is the only thing that seems to work, but produces this deprecation error....
activerecord: attributes: user: web_account/password: "Password"
This works for the view label without generating the warning. BUT, the problem with this approach is that if your nested form have any validation form and you try to display it's errors, the translation in error messages don't work.
I really think that this warning should be removed since I think there's no workaround for nested forms validation messages.
@plentz, well, either that or go with the style you described and fix the case where the error messages don't work. On the other hand, the way you describe the solution seems like a step back regarding DRY'ing up your code.
The above mentioned technique that @dmke suggested won't work anymore with the
Either way, the deprecation warning is annoying when you are developing and testing your app, to say the least, so I hope this gets resolved soon, it seems a rather small thing to fix (or revert) compared to everything that has been going on in Rails (sprockets, asset pipeline, coffee script, etc)
Sorry, seems like I misunderstood the warning I got. I genuinely had an error in my locale files.
en: activerecord: attributes: blog: title: one: Title other: Titles
Note that the attribute isn't an association. I have no idea how we ended up with this key like that.
Sorry for spamming you, José. :-(
My yml is like:
I do have a nameclash bug:
When translating the delivery_address association itself (belongs_to relationship)
Both point to
Clearly we need to implement the nested attribute look-up as
It may clash with a model named Subscription::DeliveryAddress but not likely.
I think it should fall back to
As for clashes, are there realistic use cases for
added a commit
Oct 26, 2011
hi, actually i have similar problem..
"[DEPRECATION WARNING] Nested I18n namespace lookup under "activerecord.attribute s.order" is no longer supported"
This is coming when i am running server, i am did my rake db:migrate set up and i am using sqlite3
can any body help me out...