Using code based upon an old Railscast, http://railscasts.com/episodes/142-paypal-notifications , I have been attempting to pass information about the cart to and from different parts in the site, the issue appears to be with the following code.
def create
@pProduct = Product.find(params[:product])
@item = Item.create!(:cart => current_cart, :product => @pProduct, :quantity => 1, :pPrice => @pProduct.pPrice)
flash[:notice] = "Successfully added #{@pProduct.pName}"
redirect_to current_cart_url
end
And the code to handle this input, found in the app controller.
def current_cart
if session[:cart_id]
@current_cart ||= Cart.find(session[:cart_id])
session[:cart_id] = nil if @current_cart.purchased_at
end
if session[:cart_id].nil?
@current_cart = Cart.create!
session[:cart_id] = @current_cart.id
end
@current_cart
end
The produced error is.
ActiveModel::MissingAttributeError in ItemsController#create
can't write unknown attribute `cart_id'
Rails.root: /home/timewaster/Aptana Studio 3 Workspace/cs2512
Application Trace | Framework Trace | Full Trace
app/controllers/items_controller.rb:4:in `create'
I know this is probably something ridiculously simple, but any input would be welcome as I've be slamming my head into a wall for the past half hour with this.
EDIT: As requested, routes.rb I apologise for how all over the place this one is.
http://pastebin.com/gq4Ekzvn EDIT: Turns out I'm an idiot, Schema issues suck.