Simple form question

Hi folks,

I’ve done this a few ways that have all seemed a bit ‘nobby’ so was
just wondering if there is a recommended way to achieve the following:

I have 2 models, ‘customers’ and ‘sites’ which are connected with a
has_many/belongs_to relationship.
I have the scaffold form which creates customers, which is as desired,
but I ONLY want to be able to create a site after going through
the :show page of a customer and selecting an ‘Add new Site’ link.

To do this, I can obviously just provide a link_to to the sites/new
controller, but I need to pre-populate the sites ‘customer_id’ field,
without displaying this in a way that could be manipulated (e.g. in
the URL as a parameter).

Unfortunately, I do need the ‘sites’ form to be on a separate page to
the customer show page, otherwise it would have been very easy.

Is there a better solution that POSTing to the site form with the
values from the :show page, to then POST to the create method?

Really appreciate any pointers on this,

Paul

it sounds like users can only create sites to their own customer
records. This is authorization and can do handled with something like
the cancan gem.

Sorry, didn’t explain that well; all users have access to all
customers and sites, as they manage the customer contracts.
As there will be several hundred+ customers, I am just looking for a
way to add sites for a customer without having to select the customer
each time, instead by accessing the sites/new form through a customer
record / show page