将翻译添加到现有的精简 cms 扩展



嗨,我按照 Sunil 教程进行操作,但出现以下数据库错误:

Completed 500 Internal Server Error in 11.2ms
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
Processing by Refinery::PagesController#home as HTML
Parameters: {"locale"=>:es}
SELECT a.attname, format_type(a.atttypid, a.atttypmod),
ActionView::Template::Error (PG::UndefinedTable: ERROR:
relation "refinery_project_translations" does not exist
2014-12-29T14:14:46.684169+00:00 app[web.1]:
LINE 5:              WHERE a.attrelid = '"refinery_project_translati...
2014-12-29T14:14:46.684177+00:00 app[web.1]:
ON a.attrelid = d.adrelid AND a.attnum = d.adnum

迁移文件:

class CreateProjectTranslations < ActiveRecord::Migration 
   def up 
      ::Refinery::Projects::Project.create_translation_table!({:description => :string},
      :migrate_data => true) 
      remove_column :refinery_projects, :description 
   end 
   def self.down 
      add_column :refinery_projects, :description, :string 
      ::Refinery::Projects::Project.drop_translation_table! :migrate_data => true 
   end 
end

运行迁移后,我意识到并没有为项目创建转换表。

型:

module Refinery
  module Projects
    class Project < Refinery::Core::BaseModel
      self.table_name = 'refinery_projects'
      translates :description
      attr_accessible :name, :description, :date_started, :date_conclusion,
                      :position, :relevance, :img_id, :project_id, :status 
      validates :name, :presence => true, :uniqueness => true
      has_many :project_images
      has_many_page_images
      class Translation 
           attr_accessible :locale 
      end
    end
  end
end

我在这里错过了什么?

我解决了将迁移文件从扩展名移动到应用程序迁移文件夹的问题。之后,应用程序能够为翻译创建表。

下面是

生成扩展的命令。如果要在现有文件上使用它,它将通过覆盖它们将所有必需的代码添加到现有文件中。小心这一点 - 在提交文件之前。

rails g refinery:engine Service title:string description:text icon:image --i18n title description

最新更新