I set category
's viewable
attribute as an enum
class Category < ActiveRecord::Base
enum viewable: [:only_self, :friends, :anyone]
end
How should I make them accesible in _form
when users edit this attribute? Something like?
<%= form_for(@category) do |f| %>
<%= f.select(:viewable) %>
<% end %>
UPDATE------
<%= f.select(:viewable, options_for_select([["description1", "only_self"], ["description2", "friends"], ["description3", "anyone"]])) %>
- The description for each is quite repetative, because I need to put them whenever I need to display, not just in the forms. Where should I put them?
- In
form_for
, thef.select
does not display the current value of the this field. It always is the firstdescription1
.