Search code examples
ruby-on-railsrubyradio-buttonsimple-form

Ruby gem simple_form 3.1.0 radio button


I use simple_form for displaying radio button for boolean attribute

<%= simple_form_for @model do |f| %>
   <%= f.input :is_deleted, as: :radio_buttons %>
<% end %>

But instead of 2 radio buttons with yes/no titles i see just titles yes/no and no radio buttons. What's wrong?

EDIT

here is rendered html for my code

here is rendered html for Max's code


Solution

  • Try this:

    <%= simple_form_for @model do |f| %>
      <%= f.input :is_deleted, as: :radio_buttons,  :collection => [[true, 'Yes'], [false, 'No']]  %>
    <% end %>
    

    Obviously you can substitute whatever values you want to display for "Yes" and "No"