Hello, Complete novice here. I have a line_item that once created or updated calculates the capacity left and displays it in the events view. The Add to Cart button triggers the create line_item method. I've added further capacity calculations to the line_item destroy method. My problem is that the line_item destroy method is not called when the cart is destroyed.
class Cart < ActiveRecord::Base has_many :line_items, :dependent => :destroy The line items are destroyed but the functionality in the line_item destroy method does not run. Line Item Controller ---- def destroy @line_item = LineItem.find(params[:id]) event = @line_item.event new_quantity = params[:line_item_quantity].to_i change_in_capacity = @line_item.quantity + new_quantity respond_to do |format| @line_item.destroy event.capacity = change_in_capacity event.save So I tried to add a call to it in the Cart Controller as follows ---- def destroy @cart = Cart.find(params[:id]) @line_item = LineItem.find(params[:cart_id]) @cart.destroy @line_item.destroy session[:cart_id] = nil but I can't seem to find the line item this way "Couldn't find LineItem without an ID" Any ideas? Thanks in advance from a complete beginner. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.