Ruby on Rails Saturday, March 4, 2017

On 4 March 2017 at 18:10, Joe Guerra <> wrote:
> so basically what your saying is;
> before filter: calc_remaining
> def calc_renaming
> #taken query here -- I forget what I did - not at my development
> pc...
> @remaining = @product.qty - @taken
> end
> Then call calc_renaming from the two methods I need to figure out what
> remaining is.

You won't need to call it explicitly in the methods, that is what
before_filter does. If you only need it in those two methods then
either specify that in the before filter (look at the docs for how to
do that), or don't use before filter just call it in the methods.
However if @taken is also a query on product then define a method in
product called, possibly, remaining and then in your methods just do
@remaining = @product.remaining


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
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment