1
我使用创建一个Rails 4迁移文件:Rails的生成迁移文件支架
rails g migration CreateCompanyAndAttributes
我编辑的迁移是:
def change
create_table :companies do |c|
c.integer :name
c.string :logo_url
c.timestamps
end
create_table :attributes do |a|
a.string :name
a.string :description
a.string :image
a.timestamps
end
create_table :company_attributes do |t|
t.integer :facility_id
t.integer :attribute_id
t.timestamps
end
end
现在,我的移民是准备部署,如何我可以立即为所有三个脚手架生成脚手架吗?
我应该先运行:
rake db:migrate
然后像
rails g scaffold companies
rails g scaffold attributes
rails g scaffold companies_attributes