I have 3 models:
Report
has_many :report_items, dependent: :destroy
has_many :items, through: :report_items
Item
has_many :report_items, dependent: :destroy
has_many :reports, through: :report_items
ReportItem
belongs_to :item
belongs_to :report
I scaffolded all 3 models so I now have 3 seperate views for each.
Right now if I wanted to assign an item to a report, I have to:
-
Create new Item record
-
Create new Report record
-
Create new ReportItem record, using the id's of Item and Report to tie them together.
However what I need is for ReportItem to be nested inside Report. The idea is that when I create a new report, I can go to its "show" page and assign items from there.
I've went to http://ift.tt/GVpneB to research on how this would work. However I'm still confused as to how to actually accomplish it.
Any tips on this?
Aucun commentaire:
Enregistrer un commentaire