hello all! is it possible to access the render time variables in the view? i would like to show Completed in 0.09574 (10 reqs/sec) | DB: 0.08729 (91%) | 200 OK [http://localhost/person] on each page like in the logs. how can i do this?
hello all! is it possible to access the render time variables in the view? i would like to show Completed in 0.09574 (10 reqs/sec) | DB: 0.08729 (91%) | 200 OK [http://localhost/person] on each page like in the logs. how can i do this?
Simon Santoro wrote:> hello all! > is it possible to access the render time variables in the view? i would > like to show > > Completed in 0.09574 (10 reqs/sec) | DB: 0.08729 (91%) | 200 OK > [http://localhost/person] > > on each page like in the logs. > > how can i do this?If render time can only access in a controller, Try setting up a message in controller then. Moreover, you can use flash variable to do the job since you want the message to appear every page :), Tom
Anocha Yimsiriwattana wrote:> If render time can only access in a controller, Try setting up a message in > controller then.I don''t know if it is accessible in the controller. I don''t know where to look for them...> Moreover, you can use flash variable to do the job since > you want the message to appear every page :),Oh well. Once I get to them, displaying them will be the last of th problems :)
Simon Santoro wrote:> Anocha Yimsiriwattana wrote: >> If render time can only access in a controller, Try setting up a message >> in controller then. > > I don''t know if it is accessible in the controller. I don''t know where > to look for them... > >> Moreover, you can use flash variable to do the job since >> you want the message to appear every page :), > > Oh well. Once I get to them, displaying them will be the last of th > problems :)Arr ... I thought you know how to access it in controller, my bad. I was going to ask you how to do that too :P
By definition, if you can see the page, you got a 200 response so that''s very possibly not what you want. If render time is what you''re after, an approximate way to capture that is: RAILS_ROOT/app/views/layouts/application.rb <%= @content_for_layout %> <%= sprintf(''%f'', (Time.now.usec - @start_time.usec).to_f / 1000000) %> RAILS_ROOT/app/views/layouts/controller_to_time.rb def initialize @start_time = Time.now; super end Naturally, a better way to do this would be to actually *change* ApplicationController on the fly so this initialize code happens all the time. Regarding DB, that''s kind of up to you, but a similar technique in ActiveRecord would work. By the way, Windows does not render the time to anywhere near the amount of precision *nix does. Hope this helps. -----Original Message----- From: Simon Santoro [mailto:Simon.Santoro-Syd3ARw+vPY@public.gmane.org] Sent: Monday, December 26, 2005 4:41 AM To: Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails] show render time on pages hello all! is it possible to access the render time variables in the view? i would like to show Completed in 0.09574 (10 reqs/sec) | DB: 0.08729 (91%) | 200 OK [http://localhost/person] on each page like in the logs. how can i do this?