2012-11-18 27 views
0

我想添加一个新列了一堆我的网站上不同的项目。迁移时为什么会出现错误?未初始化的常量AddDates

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

为什么你需要':createdat'?每个表都有一个'created_at'列。 – Thanh

+0

好问题。我只需要它,所以我可以补充一点,有一对夫妇的岁项目,并对其进行排序。 – lostPixels

回答

0

任何机会,迁移的文件名是不是“123123_add_createdat_to_stream_items.rb”“123123_add_dates.rb”(其中“123123”是一串数字,不一定是“123123”)?

迁移的类名和文件名需要在驼峰=> camel_case方式相匹配。

+0

这结束了我的愚蠢,一个简单的文件名的问题。 – lostPixels

相关问题