0

Is it possible to use the annotate (2.4.1.beta) gem to output globalize3 (0.2.0) translated properties in the models that they translate?

If I have a Post creation migration generated 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

and its corresponding class looking like

class Post < ActiveRecord::Base
  attr_accessible :title, :text
  translates :title, :text
end

since the :title and :text attributes are not in the posts table but in the post_translations table, when I run

$ annotate --position before

they are not included in the output for the Post model:

# == 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
...

Is there any way to include these attributes without manually typing them in after every annotation generation?

4

1 回答 1

0

目前,不幸的是,这个问题的答案是否定的,没有办法在注释生成中包含 Globalize 翻译属性。只需要继续监控annotate 的 Github repo上的开发。

于 2012-06-24T06:54:50.727 回答