我正在阅读Rails测试处方书,在设置过程中,它要求我将迁移文件更改为以下内容:
- class ProjectUserJoin < ActiveRecord::Migration
- def self.up
- create_table :projects_users,:force => true,:id => false do |t|
- t.references :project
- t.references :user
- t.timestamps
- end
- end
- def self.down
- drop_table :projects_users
- end
- end
看起来我在Rails(4.0.0)上使用的是比书(2或3.x)更高的版本,我的迁移文件如下所示:
- class ProjectUserJoin < ActiveRecord::Migration
- def change
- end
- end
如何编辑更改方法以执行与上述上下方法相同的操作?到目前为止,我尝试使用up和down而不是self.up和self.down并使用相同的代码进行复制.那没起效.
谢谢!