ruby-on-rails - Globalize3 - 尝试将翻译添加到现有模型时出现迁移错误

标签 ruby-on-rails internationalization ruby-on-rails-3.2 globalize3

我尝试使用 Globalize3 作为一种简单的方法来为名为 EventCategory 的模型提供翻译。

不幸的是,当我通过 rake db:migrate 运行迁移时,出现以下错误:

==  AddTranslationsToEventCategory: migrating =================================
rake aborted!
An error has occurred, this and all later migrations canceled:

PG::Error: ERROR:  relation "translations" does not exist
LINE 4:              WHERE a.attrelid = '"translations"'::regclass
                                    ^
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"translations"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

我开始在谷歌上搜索解决方案,并发现了这个:Relation "translations" does not exist after migrating to Rails 3.2.1

但这对我来说不起作用。

这是我的迁移:

class AddTranslationsToEventCategory < ActiveRecord::Migration
  def self.up
    EventCategory.create_translation_table!({
      :name => :string
    }, {
      :migrate_data => true
    })
  end

  def self.down
    EventCategory.drop_translation_table! :migrate_data => true
  end
end

到目前为止,还没有什么真正棘手的事情!我不明白为什么它不起作用。

我在运行 Mountain Lion 的 MacBookPro 上使用 Rails 3.2.8。 Postgres 是数据库系统。我已将我的应用程序提交到 GitHub。请在这里找到它:https://github.com/lionelrudaz/myteam2

如果您需要更多信息,请告诉我。

提前致谢!

干杯,

莱昂内尔

最佳答案

在GitHub上提交这个问题后,终于得到了Philip Arndt的帮助该问题已在 Globalize3 0.3.0 版本中得到修复。所以解决方案就是卸载 gemfile 并编辑它:

gem 'globalize3', '>= 0.3.0'

希望这有帮助。

关于ruby-on-rails - Globalize3 - 尝试将翻译添加到现有模型时出现迁移错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12873430/

相关文章:

python同时获取不同语言的文本

javascript - 更改 Aloha-Editor 的语言

ruby-on-rails - Ruby on Rails 中的多对多多态关联

ruby-on-rails - 在 Ruby 中处理无限日期(永远持续的事件)的正确方法是什么?

ruby-on-rails - 如何在 ruby​​ on rails 中将设计迁移添加到现有用户模型?

java - 如何在阿拉伯(hijri)日历中执行 'between' 并在 MySQL 中将其保存为 'date'?

ruby-on-rails-3.2 - 在 Rails 中,针对两种情况执行 block : first_or_create

ruby-on-rails - 在基于 SSL 的 Heroku 主机名上将根域重定向到 www

ruby-on-rails - ActiveRecord 在将 JSONB/Hash 与 Array 一起使用时构造不正确的 SQL

ruby-on-rails - 在 Rails activerecord 查询上链接一个额外的订单?