全球化2和迁移
我已经使用 globalize2 将 i18n 添加到旧站点。已经有很多西班牙语内容,但是它没有存储在 globalize2 表中。有没有办法通过 Rails 迁移将此内容转换为 Globalize2?
问题是我无法访问存储的内容:
>> Panel.first
=> #<Panel id: 1, name: "RT", description: "asd", proje....
>> Panel.first.name
=> nil
>> I18n.locale = nil
=> nil
>> Panel.first.name
=> nil
有什么想法吗?
I have used globalize2 to add i18n to an old site. There is already a lot of content in spanish, however it isn't stored in globalize2 tables. Is there a way to convert this content to globalize2 with a migration in rails?
The problem is I can't access the stored content:
>> Panel.first
=> #<Panel id: 1, name: "RT", description: "asd", proje....
>> Panel.first.name
=> nil
>> I18n.locale = nil
=> nil
>> Panel.first.name
=> nil
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我确信您已经以某种方式解决了这个问题,但这里是。您应该能够使用
read_attribute
方法来挖掘您要查找的内容。我只是使用以下命令将内容从主表迁移到 globalize2 翻译表中。
translates
行添加到您的模型中。将以下内容放入
config/initializers/globalize2_data_migration.rb
:使用以下内容创建迁移:
大量借用 Globalize 3 和 refinerycms。
I'm sure you solved this one way or another but here goes. You should be able to use the
read_attribute
method to dig out what you're looking for.I just used the following to migrate content from the main table into a globalize2 translations table.
translates
line to your model.Place the following in
config/initializers/globalize2_data_migration.rb
:Created a migration with the following:
Borrows heavily from Globalize 3 and refinerycms.