【问题标题】:Annotating Rails models that have Globalize3 translation tables注释具有 Globalize3 转换表的 Rails 模型
【发布时间】: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
...

有没有什么方法可以包含这些属性,而无需在每次注释生成后手动输入它们?

【问题讨论】:

标签: ruby-on-rails-3 model internationalization annotate globalize3


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2010-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多