ruby-on-rails – 未定义的方法`create_translation_table!’

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 未定义的方法`create_translation_table!’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个新的rails引擎,我想使用globalize3.我在我的lib // engine.rb中这样做了:
  1. require 'globalize3'
  2.  
  3. module SimpleCms
  4. class Engine < ::Rails::Engine
  5. end
  6. end

现在,我尝试创建这样的迁移:

  1. class CreatePages < ActiveRecord::Migration
  2. def up
  3. create_table :pages do |t|
  4. t.string :path
  5. t.timestamps
  6. end
  7. Page.create_translation_table! title: :string,body: :body
  8. end
  9.  
  10. def down
  11. drop_table :pages
  12. Page.drop_translation_table!
  13. end
  14. end

我有这个错误

  1. undefined method `create_translation_table!' for #<Class:0x00000001d5ca18>

我认为没有加载文件’lib / globalize / active_record / migration.rb’.

解决方案吗

解决方法

你必须添加
  1. translates :attributename

运行迁移之前,请转到Engine模型文件. (替换:具有您要翻译的属性的attributename).那为我修好了.

猜你在找的Ruby相关文章