【发布时间】:2012-09-17 22:28:40
【问题描述】:
globalize3 gem 的 github 页面https://github.com/svenfuchs/globalize3 清楚地概述了如何使用您想要多次翻译的字符串和文本属性来准备模型的迁移。例如:
class CreatePosts < ActiveRecord::Migration
def up
create_table :posts do |t|
t.timestamps
end
Post.create_translation_table! :title => :string, :text => :text
end
def down
drop_table :posts
Post.drop_translation_table!
end
end
如果我有某些不需要翻译的属性——例如保存 user_id 或其他整数值属性,该怎么办。我是否将它们写在下面作为 Post.create_translation_table 的一部分!声明,还是将它们留在 create_table :posts 部分的上方?
正确的EG:
def up
create_table :posts do |t|
#put it here as t.integer :user_id?
end
Post.create_translation_table! :title => string, :text => :text #user_id dec here?
end
谢谢!
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 translation globalize3