我如何处理迁移名称冲突?

时间:2013-06-17 22:25:13

标签: ruby-on-rails-3 migration rails-migrations

我安装了一个购物车gem(Piggybak),它创建了一个名为create_orders...的迁移...但我不再使用该gem,并添加了一个迁移以删除与piggybak相关的所有表。

但是,我正在尝试推出自己的购物车,当我创建一个名为create_order的新迁移时,即使它有不同的时间戳,我收到此错误:

$ rake db:migrate
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
rake aborted!
Multiple migrations have the name CreateOrders

所以...我将迁移重命名为create_non_piggybak_orders,现在收到此错误:

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

uninitialized constant CreateNonPiggybakOrders/.rvm/gems/ruby-2.0.0-p0@myapp/gems/activesupport-3.2.13/lib/active_support/inflector/methods.rb:230:in `block in constantize'

处理这种情况的最佳方法是什么?

1 个答案:

答案 0 :(得分:1)

打开迁移文件并更改类的名称以匹配camelcase中的文件,即:

class CreateNonPiggybakOrders < ActiveRecord::Migration