Default value for input with simple_form Default value for input with simple_form ruby-on-rails ruby-on-rails

Default value for input with simple_form


You can try with something like this:

<%= f.input :quantity, input_html: {value: f.object.quantity || '1'} %>


You can use the selected option of simple_form:<%= f.input :quantity, selected: f.object.quantity || '1' %>


try this:

= f.input : quantity, input_html: { value: (f.object.quantity.present?) ? f.object.quantity : '1' }