simple form question

paulo
Thu, 07 Jul 2011 12:36:32 -0000

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