Frage

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?

War es hilfreich?

Lösung

For now, unfortunately the answer to this question is no, there is no way to include Globalize translation attributes in an annotation generation. Will just need to keep monitoring development on annotate's Github repo.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top