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 now I have 3 separate 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 after I create a new report, I can go to its "show" page and create "report_items" records from there. These "report_items" records automatically use the current "report" record's id.
I've gone to http://guides.rubyonrails.org/routing.html to research on how this would work. However, I'm still confused as to how to actually accomplish it.
Any tips on this?