I have a model in Rails that has an enum attribute "status". I want to have a concept of public and private statuses, like so:
class Something < ActiveRecord::Base
@public_statuses = [:open, :closed, :current]
@private_statuses = [:deleted]
enum status: @public_statuses + @private_statuses
end
So that I can do the following in a view:
<select>
<% Something.public_statuses.each do |status| %>
<option value="<%= status %>"><%= status.humanize %></option>
<% end %>
</select>
This way, I don't expose the private statuses to the end user.
Unfortunately I don't understand Ruby classes very well and just cannot get this to work regardless of whether I do @public_statuses, @@public_statuses, public_statuses=[...] etc. I'm familiar with Java and other OO languages but just don't get what to do in Ruby here.
What is the right way to do this?