title: Rails: Enums with hashes not returning hash key:value
body: <p>I am building a Ruby on Rails Application where I have model attributes that are static like <code>Gender</code> and <code>Status</code>. I have decided to define them as <code>enums</code> in the models. I am using the <a href="https://github.com/dblock/ruby-enum" rel="nofollow noreferrer">ruby-enum</a> gem to define the enums.</p>
  
  <p>I have added the <a href="https://github.com/dblock/ruby-enum" rel="nofollow noreferrer">ruby-enum</a> gem to my project, and ran <code>bundle install</code>:</p>
  
  <pre><code>gem 'ruby-enum', '~&gt; 0.8.0'
  </code></pre>
  
  <p>However, the enums needs to be accessible by various other models, so I have defined the enums as <strong>modules</strong> in the <strong>concerns</strong> directory of my models:</p>
  
  <pre><code># app/models/concerns/status.rb
  
  module Status
    extend ActiveSupport::Concern
    included do
      include Ruby::Enum
  
      define :ordered, 'Ordered'
      define :cancelled, 'Cancelled'
      define :waiting, 'Waiting'
    end
  end
  </code></pre>
  
  <p>I have included this module in my <code>Users</code> model</p>
  
  <pre><code>class User &lt; ApplicationRecord
    include Status
  end
  </code></pre>
  
  <p>And my <code>Users</code> model has a column for <code>status</code>:</p>
  
  <pre><code>create_table "users", force: :cascade do |t|
    t.string "first_name"
    t.string "last_name"
    t.string "status"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
  end
  </code></pre>
  
  <p>But when I query the Status module in the <code>rails console</code>:</p>
  
  <pre><code>Status.all
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>NoMethodError (undefined method `all' for Status:Module)
  </code></pre>
  
  <p>When I also query the <code>User</code> Model in the rails console for all <code>statuses</code>:</p>
  
  <pre><code>User.statuses.all
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>ArgumentError (wrong number of arguments (given 2, expected 0..1))
  </code></pre>
  
  <p>I also don't know how to make this available in the views </p>
  
  <pre><code>  # app/views/users/_form.html.erb
  
    &lt;%= form.label :status %&gt;&lt;br /&gt;
    &lt;%= form.select :status, User.statuses.keys.collect { |status| status },{} %&gt;  
  </code></pre>
  
  <p>I would appreciate some help in the right direction on how to go about defining the enums and also returning the key values of the enums in the users' form view so that a status can be selected in the form. Thank you.</p>