!
:
= f.radio_button :system, "bacteria"
Bacteria
= f.radio_button :system, "mammalian"
Mammalian
= f.radio_button :system, "yeast"
Yeast
= f.radio_button :system, "insect"
Insect
%br/
= f.radio_button :system, nil, id: 'other_system_radio',
checked: radio_checked?('system', f.object.system)
Other:
%input.input-small
( , ):
def radio_checked?(type,val)
case type
when 'system'
['bacteria', 'mammalian', 'yeast', 'insect'].include?(val) ? '' : 'checked'
end
end
def text_input?(type,val)
case type
when 'system'
['bacteria', 'mammalian', 'yeast', 'insect'].include?(val) ? '' : val
end
end
Javascript "", :
@handle_other_field = ->
$('#other_system_text').focus( -> $('#other_system_radio').attr('checked','checked'))
$('#other_system_text').keyup( -> $('#other_system_radio').val($(this).val()))