These are my models:
class Product
has_many :line_items
has_many :orders, :through => :line_items
end
class LineItem
belongs_to :order
belongs_t
The accepted answer got rid of the error message, but I was still unable to save @order.line_items without getting an error telling me [:order_id, :product_id] does not exist.
I finally solved this by deleting the line_items table and recreating it with this migration:
def change
create_table :line_items do |t|
t.references :order
t.references :product
t.integer :quantity
t.timestamps
end
end
I hadn't used "references" when I created the table originally, which Rails 3 didn't mind, but made Rails 4 complain.