title: Rails Single Table Inheritance - What is the best way to explicitly set type?
body: <p>I am using <a href="http://api.rubyonrails.org/classes/ActiveRecord/Inheritance.html" rel="nofollow noreferrer">single table inheritance</a> in my rails application, and want to explicitly set the type of an instance.</p>
  
  <p>I have the following;</p>
  
  <pre><code>class Event &lt; ActiveRecord::Base
  class SpecialEvent &lt; Event
  </code></pre>
  
  <p>which is implemented through single table inheritance.</p>
  
  <p><code>SpecialEvent.new</code> works as expected, but I want to be able to do things like</p>
  
  <pre><code>Event.new(:type =&gt; 'SpecialEvent')
  </code></pre>
  
  <p>So I can create different sub_types easily in the application.</p>
  
  <p>However this doesn't work and seems to set <code>:type</code> to <code>nil</code>, not the value I set it to; I suspect this is because by calling <code>Event.new</code> it is overwriting the <code>:type</code> argument.</p>
  
  <p>Has anyone got a good way of doing this?</p>