29 Jan 2014, 19:55
Generic-user-small

Robert Sheehan (3 posts)

Could any body help me with this error im getting when i try to place an order. i cant seem to figure it out i nearly have everything working. im getting message:

can’t write unknown attribute `order_id’

(`respond_to do |format|`
     `if @order.save` 
	  `Cart.destroy(session[:cart_id])`  
		`session[:cart_id] = nil`)
30 Jan 2014, 16:45
Generic-user-small

Robert Sheehan (3 posts)

i was able to fix this by deleting the migration generate migration add_order_to_line_item order:references on page 171 to generate migration add_order_to_line_item order_id:references….. that must be an error in book

23 Oct 2014, 01:12
Generic-user-small

Nick Nish (1 post)

Might be working off an old copy or working with a new version of Rails since this hasn’t been an issue since (need to update), but thanks Robert!

You were a tad off though – it’s

rails g migration add_order_to_line_item order:references

Otherwise, it’ll add t.integer “order_id_id” to the “line_items” column in your db. You got me 90% of the way there though :)

  You must be logged in to comment