Initialising has_many through joins

Hi

What is the quick and tidy way to initialise has_many through
associations?

What I need is a form that edits the join so where no join exists a
blank field is initialised. Now using accepts_nested_attributes_for and
fields for this is very tidy and easy for existing fields, but how do I
initialise those joins as empty fields without saving them?

Something like

model

order has_many order_items
order has_many items through order_items

controller

def edit
@order = Order.find(params(id)
@order.items.merge(Items.find(:all)) # something along these lines

TIA

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs