title: Why do I get an Unknown Primary Key exception for a join table in Rails 4?
body: <p>These are my models:</p>
  
  <pre><code>class Product
    has_many :line_items
    has_many :orders, :through =&gt; :line_items
  end
  
  class LineItem 
    belongs_to :order
    belongs_to :product
  end
  
  class Order
      has_many :line_items
      has_many :products, :through =&gt; :line_items
  end
  </code></pre>
  
  <p>From schema.rb:</p>
  
  <pre><code>  create_table "line_items", id: false, force: true do |t|
      t.integer  "order_id"
      t.integer  "product_id"
      t.integer  "quantity"
      t.datetime "created_at"
      t.datetime "updated_at"
    end
  </code></pre>
  
  <p>I just upgraded to Rails 4, and my join table stopped working. If I do <code>@order.line_items</code>, it throws the exception "Unknown primary key for table line_items in model LineItem." <code>@order.products</code> works as expected. </p>
  
  <p>I have tried dropping and recreating the line_items table, and I have tried installing the protected_attributes gem, but nothing changed.</p>
  
  <p>Here is <a href="http://pastebin.com/Z5BDBFEY">the trace</a>.</p>