Using Rails 3.2.0.rc2 and ruby 1.9.3p0
In app/views/requests/_form.html.erb I have the following code for showing radio buttons to set the value of :req_driverage (@requests.req_driverage) (in the database, table requests has column req_driverage of type integer):
<%= f.label "Authorized age:" %>
<%= radio_button_tag(:req_driverage, "0") %>
<%= label_tag(:req_driverage_0, "Any driver aged 21 years and over") %>
<%= radio_button_tag(:req_driverage, "1") %>
<%= label_tag(:req_driverage_1, "Any driver aged 25 years and over") %>
<%= radio_button_tag(:req_driverage, "2") %>
<%= label_tag(:req_driverage_2, "Any driver aged 30 years and over") %>
Before sending this through actionmailer, I am viewing the value of @request.req_driverage in the log file:
logger.info("Value is #{@request.req_driverage}")
However, this is only showing “Value is “, meaning that the value is nil (undefined?), even though it has been selected before creating the object.
The strange thing is that I am seeing
"req_driverage"=>"1",
(if radio button option two was selected) in the browser, when I comment out the call to mail in the actionmailer file and get the error A sender (Return-Path, Sender or From) required to send a message.
Can anyone please guide me on what is wrong with the above erb code? Or point me to where the value of req_driverage is being changed?
Thanks
The form field helper (radio_button in your case) for model attribute must be called on the form builder object f in order to be properly included in the
paramshash.Check the guide.