加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-17 04:36:17 所属栏目:百科 来源:网络整理
导读:我有一个新的rails引擎,我想使用globalize3.我在我的lib // engine.rb中这样做了: require 'globalize3'module SimpleCms class Engine ::Rails::Engine endend 现在,我尝试创建这样的迁移: class CreatePages ActiveRecord::Migration def up create_tabl
我有一个新的rails引擎,我想使用globalize3.我在我的lib // engine.rb中这样做了:
require 'globalize3'

module SimpleCms
  class Engine < ::Rails::Engine
  end
end

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

class CreatePages < ActiveRecord::Migration
  def up
    create_table :pages do |t|
      t.string :path
      t.timestamps
    end
    Page.create_translation_table! title: :string,body: :body
  end

  def down
    drop_table :pages
    Page.drop_translation_table!
  end
end

我有这个错误:

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

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

有解决方案吗

解决方法

你必须添加
translates :attributename

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读