【发布时间】:2012-05-29 13:24:58
【问题描述】:
是否可以使用annotate (2.4.1.beta) gem 在他们翻译的模型中输出globalize3 (0.2.0) 翻译的属性?
如果我有一个Post 创建迁移生成like so
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
及其对应的类看起来像
class Post < ActiveRecord::Base
attr_accessible :title, :text
translates :title, :text
end
由于:title 和:text 属性不在posts 表中而是在post_translations 表中,所以当我运行时
$ annotate --position before
它们不包含在 Post 模型的输出中:
# == Schema Information
#
# Table name: posts
#
# id :integer not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
#
class Post < ActiveRecord::Base
...
有没有什么方法可以包含这些属性,而无需在每次注释生成后手动输入它们?
【问题讨论】:
-
在不久前 Globalize 版本 2 上时,看起来就像 this has already been asked about 直接给注释开发者。
标签: ruby-on-rails-3 model internationalization annotate globalize3