Timed tasks

Here's the situation. I have a set of tasks that need to be executed
after some specific time after they were created (say 9876 seconds).
They only need to be executed once. Also there can potentially be tens
of thousands of those tasks. The list is also dynamic means that tasks
are constantly added and time after which tasks have to be executed is
different for each task. What would you suggest?

I'd store the time when they need to be executed. Have a script that wakes up every so often (set the frequency according to your needs) and see if any of the execution times have expired. As long as you've got an index on the when it should run column it should be no problem for the database.

Fred

And how do i write a script that has access to models?

And how do i write a script that has access to models?

Use script/runner or require config/boot and config/environment or
write a rake task that depends on the environment task

Fred