I have a web-based form for applicants to enter their details, created
using form_for :applicant
There is one field in the corresponding applicants table of my database
which is not represented in the form.
I want to set the value of this field in the model (it should be an
What is the best way to do this?
Currently I am doing:
validate do |applicant|
applicant.non_represented_field = 123456789
This works, but the value assigned to the 'non-represented' field is
only available after the applicants details have been successfully
If validation fails (i.e. if an obligatory field was omitted), this
value is showing up in the hash of values that is posted to the
controller as nil (which is bad as I always want it to be set).
I would be grateful if anyone could give me an idea how to solve this.
The only other thing I could think of was setting it with some kind of
call back, but I couldn't get that to work.
Thanks in advance.