【发布时间】:2010-10-06 05:57:11
【问题描述】:
我正在尝试为仅用作枚举的简单表创建迁移。所以我想立即用它的值填充表格。我尝试了以下方法:
class CreateUserTypes < ActiveRecord::Migration
def self.up
create_table :user_types do |t|
t.column :type, :string
t.timestamps
end
end
def self.down
drop_table :user_types
end
UserType.create :type => "System administrator"
UserType.create :type => "Simulation controller"
end
但我收到此错误:
rake aborted!
An error has occurred, all later migrations canceled:
Could not find table 'user_types'
我关注Rails wiki 并希望它能够工作。
谢谢。但是您的建议似乎不起作用。好吧,我看不到琴弦。
sqlite> select * from user_types;
1||2009-02-08 12:00:56|2009-02-08 12:00:56
2||2009-02-08 12:00:57|2009-02-08 12:00:57
【问题讨论】:
标签: ruby-on-rails database-design migration