title: Creating the reverse of an association within a concern
body: <p>I have a concern that creates an association:</p>
  <pre><code># concerns/product.rb
  module Product
    extend ActiveSupport::Concern
  
    included do
      has_many :products, class_name: &quot;Product&quot;, foreign_key: :owner_id
    end
  end
  </code></pre>
  <p>And an example model:</p>
  <pre><code># models/user.rb
  class User &lt; ApplicationRecord
    include Product
  end
  </code></pre>
  <p>If I do: <code>User.products.last</code> it works fine. I also want to be able to do <code>Product.last.owner</code> but it won't work without the association being defined. I can't define it in the Product model since I have no clue to what models will include the concern that creates the association.</p>
  <p>I have tried creating the association using inverse_of:</p>
  <pre><code>class Product &lt; ApplicationRecord
    belongs_to :owner, inverse_of: :products
  end
  </code></pre>
  <p>... but it won't work, apparently it needs a class name.</p>
  <p>I've also tried reflecting on which classes the concern gets included within but it raises some strange errors when the concern gets included into several different models.</p>
  <p>How do I create the inverse of an association from within the concern?</p>