4

私は足場を作ろうとしていますが、次のように has_many 属性を生成コマンドに渡したいです:

rails generate scaffold grade name:string {has_many :sections}

これにより、壊れたモデルが生成されます。

class Grade < ActiveRecord::Base
  attr_accessible :, :name, :{has_many
end

私が必要とするものの代わりに:

class Grade < ActiveRecord::Base
  attr_accessible :name
  has_many :sections
end

生成コマンドに関係属性を渡すにはどうすればよいですか?

4

1 に答える 1

11

Currently the only thing that you can do with scaffolding is adding a reference in the model you want the belongs_to

rails generate model Sections name:string grade:references

There are ways to generate with relations, but it is not Rails standard scaffolding. There are a lot of options to do that like:

Ubiquo_Scaffold

于 2012-10-25T13:08:10.033 に答える