* Jean-Christophe Michel ([EMAIL PROTECTED]) [051230 17:33]:
> I'm wondering if there is a simple solution to call a method once per
> page request.
> 
> I tried to place my call in a before_filter in ApplicationController but
> it'd called a second time if I use render_component from a view.
> Seems to me that a hook should be added in Dispatcher#prepare_application.

Seems like a before_filter should be sufficient, simply

def my_method
  return true if @@my_method_called
  @@my_method_called = true
  # do something
end

Perhaps if this is a common idiom, there's a call for a :once modifier
to before_filter / after_filter (which would do essentially the above)
instead of defining a new hook?

Rick
-- 
 http://www.rickbradley.com    MUPRN: 850
                       |  could forbid lock()ing
   random email haiku  |  readonly packages. Not
                       |  sure which was better.
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to