Hi,
If an admin is logged in, I'm trying to display how long the page took to render, somewhere at the bottom of the page.
I tried with an around_filter :time_an_action in application.rb
def time_an_action started = Time.now yield @time_to_render = Time.now - started end
In the layout I added this line: <%= @time_to_render%>
However, as the time_an_action method has already yielded the page before the instance variable @time_to_render has been given a value, it does not display it.
Trying to execute an AJAX call inside the filter or redirecting to another action, for example: def time_an_action started = Time.now yield @time_to_render = Time.now - started redirect_to :controller => "admin", :action => "display_time" end
def display_time render :update do |page| page.replace_html "time_to_render", @time_to_render end end
Gives the error of "You can't render or redirect twice in the same action"...
Any suggestions?
Thanks!
Rai