Hi all,
I'm looking to create a cross-platform (iOS, Android, Web) chat up for a
research interest in linguistics and language (if you're interested:
www.twoptzero.co ).
I'm sure most experienced developers (ruby/rails enthusiasts or not) agree
that you should pick the right tool for the
On Sun, Mar 5, 2017 at 11:03 AM, Joe Guerra wrote:
> it is set up in the private section
>
> def set_product
> @product = Product.find(params[:id])
> end
That's the method *definition*, but where are you calling it for this
request?
Every request sets up its own
On 5 March 2017 at 19:03, Joe Guerra wrote:
> it is set up in the private section
>
> def set_product
> @product = Product.find(params[:id])
> end
>
>
> and I can see it in my show method...
>
>
> How do I get to see it in my
>
>
> def calc_remaining
> @taken =
it is set up in the private section
def set_product
@product = Product.find(params[:id])
end
and I can see it in my show method...
*How do I get to see it in my *
def calc_remaining
@taken = Cart.where('product_id' => @product).count
@remaining = @product.qty - @taken
end
method?
You’re getting no method error “qty” because @product is not set in your
controller action. So you’re essentially trying to subtract @taken from
something that is NIL.
You need to see @product as an instance variable in your specific controller
method and this should work out for you.
-James
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
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
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
8 matches
Mail list logo