[Rails] Rails 5 and Cross-platform Chat Apps (Right tool for the job?)

2017-03-05 Thread Robert
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

Re: [Rails] show method variable

2017-03-05 Thread Hassan Schroeder
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

Re: [Rails] show method variable

2017-03-05 Thread Colin Law
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 =

Re: [Rails] show method variable

2017-03-05 Thread Joe Guerra
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?

Re: [Rails] show method variable

2017-03-05 Thread James Jelinek
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

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