This is basically a nested form question, albeit with only one field that belongs to a parent model. My data entry form collects data for a model - however I also need to collect one other a data element/value (UserID) that actually goes into a parent record that will be created with the detail record.
AFAIK Rails expects each form field to map to a model and I need to create an unbound data input field that I will use separately.
How can I override this default behaviour and create a'free form/unbound field'?
TIA, BC
For the "magic" form <=> model mapping
form_for
is used. (http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html)If you need something out of the current model try using http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html
With that you can add tags separate from the model, eg
inside the
form_for
blockHeres something from my own app:
Access it by:
Controller:
View: