title: Is it possible to build a dynamic chainable scope?
body: <p>Suppose I have these three models</p>
  
  <pre><code>class Plant &lt; ActiveRecord::Base
    has_many :pots
    has_many :fertilizers
  end
  
  class Pot &lt; ActiveRecord::Base
    belongs_to :plant
  end
  
  class Fertilizer &lt; ActiveRecord::Base
    belongs_to :plant
  end
  </code></pre>
  
  <p>Each one has an attribute of <code>grouped_by</code>.</p>
  
  <p>Is it possible to make a <code>grouped_as</code> scope that can be applied at the end of of either :</p>
  
  <pre><code>@plant.pots.grouped_as('outdoors')
  @plants.fertilizers.grouped_as('outdoors')
  </code></pre>
  
  <p>So that I could add <code>grouped_as</code> as a chainable scope to any relation, and it would automagically look for a common attribute between the <code>Plant</code> and its dynamic children, <code>pots</code> or <code>fertilizers</code>..</p>
  
  <p>Or would I have to just make a custom scope for each one?</p>