title: Use of the "_type" column with polymorphic associations in Rails
body: <p>I have a Slot model, belonging to the Configuration model as well as another model:</p>
  
  <p>In db/migrate/...create_slots.rb:</p>
  
  <pre><code>  t.references :slottable, :polymorphic =&gt; true
  </code></pre>
  
  <p>In app/models/slot.rb:</p>
  
  <pre><code>  belongs_to :slottable, :polymorphic =&gt; true
  </code></pre>
  
  <p>In app/models/configuration.rb:</p>
  
  <pre><code>  has_many :slots, :as =&gt; :slottable
  </code></pre>
  
  <p>In rails console I get:</p>
  
  <pre><code>  ruby-1.9.2-p180 :009 &gt; Slot.last
  
     =&gt; #&lt;Slot id: 69, slottable_id: 35, slottable_type: "configuration", number: 2, usage: "1GB 667MHz DDR2 SDRAM PC2-5300 SO-DIMM", created_at: "2011-08-09 12:12:25", updated_at: "2011-08-09 12:12:25"&gt; 
  
     ruby-1.9.2-p180 :009 &gt; Slot.last.slottable
  
     NameError: wrong constant name configuration
  </code></pre>
  
  <p>The only explanation I can come up with is that I've misunderstood the use of the slottable_type column. Have I?</p>
  
  <p>At present, in app/models/configuration.rb:   </p>
  
  <pre><code>slot = Slot.find_or_create_by_slottable_id_and_slottable_type(self.id, "configuration")
  </code></pre>