On 4 March 2017 at 18:10, Joe Guerra <[email protected]> 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

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/CAL%3D0gLs7riaChWmwXabEtoPmh8b7aac1ntJGhT-_jtDGvPtT7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to