Here is a piece of code in edit.html.erb which does not work. The purpose of the code is to fill a form for editing. Collection is used with option of yes and no. How can I set the collection to the current 'active' value with :selected option?
<%= simple_form_for @category do |f| %>
<%= f.input :name, :disabled => true, :required => false %>
<%= f.input :description %>
<%= f.input :active, :collection => ['Yes', 'No'], :selected => f.active %>
<%= f.button :submit %>
<% end %>
The error saying the active is not a method in f.input :active, :collection.
Assuming the active
attribute for categories is a boolean, try:
:selected => (@category.active? ? 'Yes' : 'No')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With