On 3 March 2017 at 22:39, Joe Guerra <[email protected]> wrote: > ok, I thought about that. Would it be ok to like set the instant variable > to a global and use that? > > $remaining = @remaining > > I tried that, and it seems to have worked. I not sure if it's the best > practice though.
Definitely not. In addition to the fact that presumable @remaining is different for different products, and a request for a different product could come in between the two requests you are interested in (so the global would be set for the wrong product) consider the case where your app becomes popular enough to be distributed over multiple instances of the server. In that case the two requests might go to different servers so the global would not be setup for the second one. Also consider that when using something like nginx to run your production site that if it is not used for a while nginx may shutdown the app and restart it when the next request comes in. Again the global would not be set. I suggest following Hassan's advice. Colin > > On Friday, March 3, 2017 at 5:21:22 PM UTC-5, Colin Law wrote: >> >> On 3 March 2017 at 22:03, Joe Guerra <[email protected]> wrote: >> > Ok, how do I deal with that? >> >> You have to recalculate the variable in each method that you need it. >> >> Colin > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/46af96c5-857d-4742-894d-be66446bf1a0%40googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtCBNZTmGf4Oq-sqgtpt5JMzw3rro193%3DG%2BYVusGMB3xA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

