title: Error when fetching a has_many association, TypeError: can't convert String into Integer
body: <p>Note: Full code can be found at <a href="http://github.com/basicxman/andrewhorsman.net" rel="nofollow">http://github.com/basicxman/andrewhorsman.net</a></p>
  
  <p>I have a <code>Tag</code> model and an <code>Article</code> model which are in a HABTM relationship via a <code>Tagging</code> model.  When I try to do a <code>find</code> query on <code>Article</code> while including the association, it fails.</p>
  
  <pre><code>ruby-1.9.2-p136 :003 &gt; Article.find(:all, :include =&gt; :tags)
    Article Load (0.3ms)  SELECT "articles".* FROM "articles" 
    Tagging Load (0.2ms)  SELECT "taggings".* FROM "taggings" WHERE "taggings"."article_id" IN (1)
  TypeError: can't convert String into Integer
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader/association.rb:83:in `[]'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader/association.rb:83:in `associated_records_by_owner'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader/collection_association.rb:13:in `preload'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader/association.rb:19:in `run'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader.rb:128:in `block (2 levels) in preload_one'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader.rb:127:in `each'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader.rb:127:in `block in preload_one'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader.rb:126:in `each'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader.rb:126:in `preload_one'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader.rb:105:in `preload'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader.rb:94:in `block in run'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader.rb:94:in `each'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader.rb:94:in `run'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader/through_association.rb:31:in `through_records_by_owner'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader/through_association.rb:15:in `associated_records_by_owner'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader/has_many_through.rb:8:in `associated_records_by_owner'
  ... 8 levels...
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader.rb:94:in `block in run'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader.rb:94:in `each'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/associations/preloader.rb:94:in `run'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/relation.rb:119:in `block in to_a'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/relation.rb:118:in `each'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/relation.rb:118:in `to_a'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/relation/finder_methods.rb:155:in `all'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/relation/finder_methods.rb:105:in `find'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/relation/finder_methods.rb:101:in `find'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.1.0.rc4/lib/active_record/base.rb:444:in `find'
    from (irb):3
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.1.0.rc4/lib/rails/commands/console.rb:45:in `start'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.1.0.rc4/lib/rails/commands/console.rb:8:in `start'
    from /Users/basicxman/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.1.0.rc4/lib/rails/commands.rb:40:in `&lt;top (required)&gt;'
    from script/rails:6:in `require'
    from script/rails:6:in `&lt;main&gt;'ruby-1.9.2-p136 :004 &gt; 
  </code></pre>
  
  <p>Here's what the current records look like:</p>
  
  <pre><code>ruby-1.9.2-p136 :005 &gt; Article.all
    Article Load (0.3ms)  SELECT "articles".* FROM "articles" 
   =&gt; [#&lt;Article id: 1, title: "testing", author: "test", content: "ohi", published_at: nil, stage: 0, last_commit_date: nil, created_at: "2011-07-01 07:06:08", updated_at: "2011-07-01 07:06:08", content_html: nil, hash: "84faf770-85de-012e-112f-109add4b71f4"&gt;] 
  ruby-1.9.2-p136 :006 &gt; Tagging.all
    Tagging Load (0.3ms)  SELECT "taggings".* FROM "taggings" 
   =&gt; [#&lt;Tagging id: 1, article_id: 1, tag_id: 1, created_at: "2011-07-01 07:06:19", updated_at: "2011-07-01 07:06:19"&gt;] 
  ruby-1.9.2-p136 :007 &gt; Tag.all
    Tag Load (0.3ms)  SELECT "tags".* FROM "tags" 
   =&gt; [#&lt;Tag id: 1, keyword: "testing", created_at: "2011-07-01 07:06:19", updated_at: "2011-07-01 07:06:19"&gt;] 
  </code></pre>
  
  <p>And the three models,</p>
  
  <p><em>Article.rb</em></p>
  
  <pre><code>class Article &lt; ActiveRecord::Base
    has_many :taggings, :dependent =&gt; :destroy
    has_many :tags, :through =&gt; :taggings
  </code></pre>
  
  <p><em>Tag.rb</em></p>
  
  <pre><code>class Tag &lt; ActiveRecord::Base
    has_many :taggings, :dependent =&gt; :destroy
    has_many :articles, :through =&gt; :taggings
  </code></pre>
  
  <p><em>Tagging.rb</em></p>
  
  <pre><code>class Tagging &lt; ActiveRecord::Base
    belongs_to :article
    belongs_to :tag
  </code></pre>