Ok I have fix it in the end, this is the code which is now working
Code:
class StoreController < ApplicationController
def index
@products = Product.salable_items
end
def add_to_cart
product = Product.find(params[:id])
@cart = find_cart
@cart.add_product(product)
redirect_to(:action => 'display_cart')
end
def display_cart
@cart = find_cart
@items = @cart.items
end
private
def find_cart
session[:cart] ||= Cart.new
end
end
the add_to_cart( ) method is called as a action and it has to be add it above the private method.
thanks for your support, even that in the end i fix it but still i am happy to be a member of this community.
best regards dan,
Bookmarks