I'm trying to make a scaffold but want to pass a has_many attribute to the generate command as follows:
rails generate scaffold grade name:string {has_many :sections}
This generates the broken model:
class Grade < ActiveRecord::Base
attr_accessible :, :name, :{has_many
end
instead of what i need:
class Grade < ActiveRecord::Base
attr_accessible :name
has_many :sections
end
How can i pass a relationship attribute to the generate command?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With