i am working on Order app with cart and line_items in it. Facing problem while deleting line_item in cart. On clicking remove item, nothing happens. Can anyone tell, where i am going wrong? My cart.html.erb in orders
<% @order.line_items.each do |item| %>
<%= link_to "remove item", item, :method => :delete, :confirm => "Are you sure?",:remote => true %>
<% end %>
My orders controller have:
def cart
@order = current_or_guest_user.orders.includes(:line_items=>[:product]).last
end
And i have defined delete item method in line_items controller:
def destroy
line_item.destroy
redirect_to cart_orders_path
end
Order model is:
belongs_to :user
attr_accessible :completed_at, :email, :item_total, :number, :payment_state, :payment_total, :special_instructions, :state, :total
has_many :line_items, :dependent => :destroy
Line item model is:
belongs_to :product
belongs_to :order
attr_accessible :price, :quantity, :product_id
Can anyone help me?