title: How to build dynamic enums in Rails 6 model concerns?
body: <p>I'm trying to build a <code>Bookable</code> model concern that adds an enum to the including model, that's used for tracking the stage of the booking:</p>
  
  <pre class="lang-rb prettyprint-override"><code>module Bookable
    extend ActiveSupport::Concern
  
    STAGES = {
      confirmed: 0,
      completed: 1,
      cancelled: 2,
      issue_raised: 3
    }.freeze
  
    included do
      enum stage: STAGES.merge(self.extra_stages)
  
      belongs_to :customer
      belongs_to :provider
      validates :stage, presence: true
  
      def self.extra_stages
        {}
      end
    end
  end
  </code></pre>
  
  <p>The <code>STAGES</code> constant defines available stages, however I want including models to be able to add stages that are specific to them, by overriding the <code>self.extra_stages</code> method. For example, in a <code>Mission</code> model:</p>
  
  <pre class="lang-rb prettyprint-override"><code>class Mission &lt; ApplicationRecord
    include Bookable
  
    def self.extra_stages
      {
        awaiting_estimate: 4,
        awaiting_payment: 5,
        awaiting_report: 6,
        report_sent: 7
      }
    end
  end
  </code></pre>
  
  <p>However, this code fails:</p>
  
  <pre class="lang-sh prettyprint-override"><code>$ bundle exec rails c
  Loading development environment (Rails 6.0.2.2)
  [1] pry(main)&gt; Mission.stages
  NoMethodError: undefined method `extra_stages' for Mission (call 'Mission.connection' to establish a connection):Class
  Did you mean?  extract_associated
  from /home/gueorgui/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.2.2/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
  </code></pre>
  
  <p>Any clue as to what I might be doing wrong? Thank you in advance!</p>