迁移时为什么会出现错误?未初始化的常量AddDates

时间:2012-11-18 17:18:02

标签: ruby-on-rails

我想在我的网站上为一堆不同的项目添加一个新列。

class AddCreatedatToStreamItems < ActiveRecord::Migration
  def change
    add_column :stream_artworks, :createdat, :date
    add_column :stream_experiments, :createdat, :date
    add_column :stream_photographies, :createdat, :date
    add_column :stream_webs, :createdat, :date
    add_column :stream_socials, :createdat, :date
  end
end

1 个答案:

答案 0 :(得分:0)

迁移的文件名有可能是“123123_add_dates.rb”而不是“123123_add_createdat_to_stream_items.rb”(其中'123123'是一串数字,不一定是'123123')?

迁移的类名和文件名需要在CamelCase中匹配=&gt; camel_case方式。