Ok i think i know what you are doing now. I would suggest writing
something like this in your ./lib directory (named timer.rb in this
case):
class Timer
@end_time
attr_writer :time
def initialize(end_time)
@end_time = end_time
end
def time_remaining
@end_time - Time.now
end
def time_up?
time_remaining <= 0
end
end
Of course this is really rough, and there are no date conversions from
milliseconds to other increments. However it is a good starting point.
Now you can simply create a session that holds an instance of the timer
object. Something like this in your controller:
def authorize
#your authorization code
session[:timer] = Timer.new(Time.now + 5.minutes)
end
Then you can use this session in your views to set the countdown times
in javascript:
<% javascript_tag do -%>
function show_timer(){
var start_time = <%= session[:timer].time_remaining %>;
//rest of your display code here
}
<% end -%>
This way, you will be able to access the time across posts!
HTH,
Aldo Sarmiento
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---