On 24 February 2011 19:40, Exequiel Fuentes <[email protected]> wrote:
>
> On Thu, Feb 24, 2011 at 4:29 PM, Mauro <[email protected]> wrote:
>>
>> On 24 February 2011 17:48, exequiel <[email protected]> wrote:
>> >> But if I want fetch the operator only once at application startup?
>> >
>> > I guess you can set up a session variable to make sure to call only
>> > once.
>> >
>> > if !session[:operator_called]
>> >  ...
>> >  session[:operator_called] = true
>> > end
>> >
>> In a method of application controller?
>
> It's just an example, you can add that piece of code in any method, for
> example:
> class ApplicationController < ActionController::Base
>   ...
>   before_filter :call_operator_once
>   ...
>   def call_operator_once
>     if !session[:operator_called]
>       fetch_operator()
>       !session[:operator_called] = true
>     end
>   end
> end

Yes but it executes the call_operator before each action of each
controller in my application.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to