Set default value for form field

Hi,

This is the controller:
@thermo_detector = ThermoDetectorOrderLetter.find(@params[:id])

@thermo_detector[:number_of_element] = '1 Element' # this is ok
@number_of_element_helper['1element'] = 'bla' # not ok

This is the view:
<%= radio_button(:thermo_detector, :number_of_element, ‘1 Element’)
%>1 Element <%= text_field(‘number_of_element_helper’, ‘1element’)
%>

another radio button

This line is source of my problem:
@number_of_element_helper[‘1element’] = ‘bla’

It made me got this error:
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.[]=

If I comment that, the code works:
radio_button with value ‘1 Element’ is checked, but the text field is
empty. How do I send value from controller to this text field
text_field(‘number_of_element_helper’, ‘1element’) where
number_of_element_helper is not variable from model???

Thank you.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs