Search code examples
ruby-on-rails-3functionexecute

How to execute a function automatically without a trigger in Rails application?


I want a function to get executed in a Rails application at a specific point of time without the intervention of a person clicking the link or triggering the function by himself/herself....

Is Threads a way to achieve it or is there any other simpler way to achieve the functionality I want to have??

Thanks in advance.


Solution

  • Could you please provide a code sample of what exactly do you want to call, execute etc... as it would be easier to tailor any solution/solutions.

    My stub at answering your query is that I have recently implemented a 'reminders' system which at given time intervals sends out, surprise here, reminder emails. To achieve this I have used 'delayed-job' gem (https://github.com/tobi/delayed_job) which allowed me to enqueue given reminders to be executed at specific time intervals picked up by the user(but this may as well be set up by you in your app .ei. each monday trigger some code logic). Threads could as well be a way to achieve your goal given that you provide more explanation and code.