Answers for "rails enumerator"

1

rails enumerize

class Moses
	extend Enumerize
    
    enumerize :status, in: %i[pending approved rejected], predicates: true, scope: true
end

# helpfulinstance methods
object = Moses.new

object.pending?
object.approved?
object.rejected?

# helpfule class methods
Moses.status.values
=> ["pending", "approved", "rejected"]
Moses.status.options

<%= form_for @user do |f| %>
  <%= f.select :status, Moses.status.options %>
<% end %>


Visit Enumerize Github: https://github.com/brainspec/enumerize
Posted by: Guest on October-19-2021

Browse Popular Code Answers by Language