As soon as I did not try - before applying to rails - the buttons work fine, but as soon as I apply it in the form - they become not clickable. Can there be a separate online guide on how to use different html / css effects to rails? I searched, but found nothing - where everything would be shown with specific examples. I would appreciate an example of proper overlay.

html:

<input type="radio" id="demo-priority-normal" name="demo-priority"> <label for="demo-priority-normal">3</label> <input type="radio" id="demo-priority-high" name="demo-priority"> <label for="demo-priority-high">7</label> 

rails:

 <%= f.radio_button :three, '3_days', checked: true %> <%= f.label :three, 'До 3 дней', value: '3_days' %> <%= f.radio_button :seven, '7_days', checked: false %> <%= f.label :seven, 'До 7 дней', value: '7_days' %> 

Update:

Created the Expectation model and associated it with Shipment through the Shipment_Association model. Then added a collection of radio buttons to the form. The radio buttons work fine, but the result is the same - when creating, all values ​​remain nil.

Shipment model:

 belongs_to :user belongs_to :friendship has_many :shipment_expectations has_many :expectations, through: :shipment_expectations 

Expectation model:

 has_many :shipment_expectations has_many :shipments, through: :shipment_expectations 

ShipmentExpectation model:

 belongs_to :shipment belongs_to :expectation 

The form:

 <%= f.collection_radio_buttons :expectation_ids, Expectation.all, :id, :name %> 

    1 answer 1

    Simply. Open up. Documentation.

    ... and find the method used there: in the search field in the upper left, type the name of the method ( radio_button ), see two matches , compare their documentation, do not find the differences and look at any of them . Note the following:

    If you want to make it checked: true the options hash. You may pass HTML options there as well.

    That is, in the options hash, you can directly write HTML attributes, in the same hash, where you have the key :checked (by the way, it has the default value false , in such cases it is not necessary to specify it explicitly).

     <%= f.radio_button :three, '3_days', checked: true, id: 'demo-priority-normal' %> 

    Well, in this particular case, everything is quite simple, and if there are several methods and they are different? Then arm yourself with a crowbar ( pry ) :

     <%= form_for :whatever do |f| %> <% binding.pry %> <% end %> 

    When rendering the page, this should throw you into an interactive Ruby session at the point where the binding.pry lies, that is, the variable f is available there, which can be closely examined. Let's say you can see her class:

     > f.class => ActionView::Helpers::FormBuilder 

    ... or even open the documentation:

     > show-doc f.radio_button ...вывод довольно большой и совпадает с тем, что в документации 

    ... or even its source code! If "not enough" :)

     > show-source f.radio_button 

    I recommend to add pry-rails , pry-byebug and pry-doc gems for debugging: replacing rails console , integration with the debugger and documentation for the standard library.