title: Rails belongs_to does not set foreign key id with custom class name
body: <p>I have my models setup like so:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_many :posts, :foreign_key =&gt; 'author_id'
  end
  
  class Post &lt; ActiveRecord::Base
    belongs_to :author, :class_name =&gt; 'User'
  end
  </code></pre>
  
  <p>Assuming:</p>
  
  <pre><code>p = Post.first # just any post instance
  a = User.first # any user instance
  </code></pre>
  
  <p>Now this piece of code is acting very weird</p>
  
  <pre><code>p.author = a
  </code></pre>
  
  <p>After setting the author, the attribute <code>author_id</code> of the post should be set to the id of the user. But this isn't happening.</p>
  
  <p>I tried using models with <code>belongs_to</code> that does not have the <code>class_name</code> parameter and everything works as expected.</p>
  
  <p>Now, one more thing that makes it weirder is that when I change the association to <code>belongs_to :author, :class_name =&gt; 'User', :foreign_key =&gt; 'author_id'</code>, it surprisingly works.</p>
  
  <p>Is this a bug in Rails 3.0.9? Shouldn't the foreign key parameter be unnecessary because as the docs say, its default value is the name of the association appended with <code>_id</code>.</p>
  
  <p>Also note that even without <code>:foreign_key =&gt; 'author_id'</code>, everything else regarding the association works as expected. (Like fetching the associated model) The only thing not working is the setter method not setting the foreign key.</p>
  
  <p>I know I could just do <code>p.author_id = a.id</code> or just add <code>:foreign_key</code> params to all my associations with <code>class_name</code>, but I prefer the more elegant syntax of <code>p.author = a</code></p>