Frage

I am working on building an Asset Tracker. In my application I have 'Assets' which user checks out for a period say Wed 8a.m to Friday 8 a.m. Now I want this to be made recurring as well. So a recurring reservation every week from Wed 8 to Friday 8 for the the say 5 coming weeks should be made feasible.I will later have queries where I would want to check if the reservation has a collision with another such recurring reservation or a non-recurring reservation.

I found ice_cube quite awesome for recurring events but there is no concept of a duration. What is the cleanest way to deal with durations? And ofcourse I am not talking of a final end duration but a recurring duration.

War es hilfreich?

Lösung

'ice_cube' allows you to specify a :duration parameter in seconds in the initialize method for a schedule to have a recurring duration.

I missed out on it earlier. This should solves the problem.

Andere Tipps

You can use cron jobs for handling recurring tasks. Check out the Whenever gem. Also have a look at this Railscast which uses the Whenever.

From Whenever:

every 3.hours do
  runner "MyModel.some_process"
  rake "my:rake:task"
  command "/usr/bin/my_great_command"
end

every 1.day, :at => '4:30 am' do
  runner "MyModel.task_to_run_at_four_thirty_in_the_morning"
end

every :hour do # Many shortcuts available: :hour, :day, :month, :year, :reboot
  runner "SomeModel.ladeeda"
end
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top