title: Rails 4: Has_one polymorphic association not working
body: <p>I have two models <code>Purchase</code> and <code>Address</code>. I'm trying to make <code>Address</code> polymorphic so I can reuse it in my <code>Purchase</code> model for <code>has_one :billing_address</code> and <code>has_one :shipping_address</code>. Here's my schema:</p>
  
  <pre><code>create_table "addresses", force: true do |t|
    t.string   "first_name"
    t.string   "last_name"
    t.string   "street_address"
    t.string   "street_address2"
    t.string   "zip_code"
    t.string   "phone_number"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "state_id"
    t.string   "city"
    t.string   "addressable_type" #&lt;-- 
    t.integer  "addressable_id"   #&lt;--
  end
  </code></pre>
  
  <p>address model:</p>
  
  <pre><code>class Address &lt; ActiveRecord::Base
    belongs_to :addressable, polymorphic: true
    ...
  end
  </code></pre>
  
  <p>purchase model:</p>
  
  <pre><code>class Purchase &lt; ActiveRecord::Base
    has_one :shipping_address, as: :addressable
    has_one :billing_address, as: :addressable
    ...
  end
  </code></pre>
  
  <p>Everything looks fine to me, but my Rspec tests fail:</p>
  
  <pre><code>    Failures:
  
        1) Purchase should have one shipping_address
           Failure/Error: it { should have_one(:shipping_address) }
             Expected Purchase to have a has_one association called shipping_address (ShippingAddress does not exist)
           # ./spec/models/purchase_spec.rb:22:in `block (2 levels) in &lt;top (required)&gt;'
  
        2) Purchase should have one billing_address
           Failure/Error: it { should have_one(:billing_address) }
             Expected Purchase to have a has_one association called billing_address (BillingAddress does not exist)
           # ./spec/models/purchase_spec.rb:23:in `block (2 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>It doesn't seem to be detecting that the association is polymorphic. Even in my console:</p>
  
  <pre><code>    irb(main):001:0&gt; p = Purchase.new
      =&gt; #&lt;Purchase id: nil, user_id: nil, order_date: nil, total_cents: 0, total_currency: "USD", shipping_cents: 0, shipping_currency: "USD", tax_cents: 0, tax_currency: "USD", subtotal_cents: 0, subtotal_currency: "USD", created_at: nil, updated_at: nil, status: nil&gt;
      irb(main):002:0&gt; p.shipping_address
      =&gt; nil
      irb(main):003:0&gt; p.build_shipping_address
      NameError: uninitialized constant Purchase::ShippingAddress
  </code></pre>
  
  <p>What am I doing wrong??</p>