【发布时间】:2010-09-19 21:51:55
【问题描述】:
我尝试在 Rails 中创建一个如下所示的数据库迁移:
ruby 脚本/生成脚手架帖子 user_id:int 标题:字符串内容:文本查看生成的 .rb 文件,果然,我看到了我输入的所有内容:
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.int :user_id # there it is: user_id
t.string :title
t.text :content
t.timestamps
end
end
def self.down
drop_table :posts
end
end
但是在运行rake db:migrate 并检查我的数据库后,我发现没有创建user_id 列。发生了什么事,这里?
【问题讨论】:
标签: ruby-on-rails activerecord migration rake reserved-words