title: Single table inheritance scopes
body: <p>Is it possible to set-up a scope on a single table inheritance that returns the subclass?</p>
  
  <p>For example:</p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
    scope :sticky, -&gt; { where(type: 'StickyPost') }
  end
  
  class StickyPost &lt; Post
  end
  </code></pre>
  
  <p>Now, when I call <code>sticky</code> on a collection of posts I get a collection of <code>StickyPost</code> instances.</p>
  
  <p>But when I call <code>posts.sticky.build</code>, the <code>type</code> is set to <code>StickyPost</code>, but the class still is <code>Post</code>.</p>
  
  <pre><code>posts.sticky.build
  =&gt; #&lt;Post id: nil, message: nil, type: "StickyPost", created_at: nil, updated_at: nil&gt;
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>Apparently this works.</p>
  
  <pre><code>posts.sticky.build type: 'StickyPost'
  =&gt; #&lt;StickyPost id: nil, message: nil, type: "StickyPost", created_at: nil, updated_at: nil&gt;
  </code></pre>
  
  <p>Which is strange, since the scope already sets the type, it seems a bit redundant. Any way to set this behaviour in the scope?</p>