から足場を生成します。Railsは、私が使用してRailsの4移行ファイルを作成した移行ファイル
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
今私の移行が展開される準備ができていること私はすぐに3つすべての足場を作成してテーブルを作成できますか?
私が最初に実行する必要があります:
rake db:migrate
その後
rails g scaffold companies
rails g scaffold attributes
rails g scaffold companies_attributes