ruby on rails - Showing the data received from db in radio_button_tag -


versions: rails 4.2.5 & ruby 2.2. using radio_button_tag in form_tag.

- options = ['yes', 'no'] - options.each |option|   = radio_button_tag 'val[0]', '#{option}', false   = label_tag( "#{option}") 

while saving, data saved properly(we saving data hash) & retrieved properly. data not reflected in radio_button_tag.

for have added radio_button_tag as:

= radio_button_tag 'val[0]', '#{option}', @value[:val][0] 

its selects 'no' radio button. html generated has both checked='checked'.

how can fix this?

we changed code this:

  = radio_button_tag 'val[0]', 1, @value[:val][0] == '1'   %label{for: 'val_0_1'} yes   = radio_button_tag 'val[0]', 0, @value[:val][0] == '0'   %label{for: 'val_0_0'} no 

we getting strings database, unable process further & in html, both comes checked, selects last one.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -