Re: [Rails] Re: show method variable

2017-03-05 Thread Joe Guerra
It works fine in the show method, but fails in add_to_cart. On Sunday, March 5, 2017 at 1:37:54 PM UTC-5, Hassan Schroeder wrote: > > On Sun, Mar 5, 2017 at 10:23 AM, Joe Guerra > wrote: > > > def calc_remaining > > @taken = Cart.where('product_id' => @product).count

Re: [Rails] Re: show method variable

2017-03-05 Thread Hassan Schroeder
On Sun, Mar 5, 2017 at 10:23 AM, Joe Guerra wrote: > def calc_remaining > @taken = Cart.where('product_id' => @product).count > > @remaining = @product.qty - @taken > end > but when I call it from my add to cart method, @product.qty is undefined > method `qty' for

[Rails] Re: show method variable

2017-03-05 Thread Joe Guerra
ok, here's my method... def calc_remaining @taken = Cart.where('product_id' => @product).count @remaining = @product.qty - @taken end but when I call it from my add to cart method, @product.qty is undefined method `qty' for nil:NilClass. On Thursday, March 2, 2017 at 11:07:06 AM