title: Create model in rails console with association?
body: <p>I currently have 2 models setup:</p>
  
  <pre><code>class Topic &lt; ActiveRecord::Base
    belongs_to :category
  end
  
  class Category &lt; ActiveRecord::Base
    has_many :topics
  end
  </code></pre>
  
  <p>I am now trying to create a topic with a category associated in the rails console:</p>
  
  <pre><code>t = Topic.new :name =&gt; "Test", :category =&gt; Category.find(1)
  </code></pre>
  
  <p>Trouble is the model has category_id, and so I'd need to use:</p>
  
  <pre><code>c = Category.find(1)
  t = Topic.new :name =&gt; "Test", :category_id =&gt; c.id
  </code></pre>
  
  <p>But, I've seen many times the ability to simply use :category instead of :category_id and pass in the category object instead of the objects id. Where am I going wrong?</p>
  
  <p>When I do:</p>
  
  <pre><code>c = Category.find(1)
  t = Topic.new :name =&gt; "Test", :category =&gt; c
  </code></pre>
  
  <p>I receive:</p>
  
  <pre><code>ActiveRecord::UnknownAttributeError: unknown attribute: category
  </code></pre>