I need to store data from a cron job in Ruby on Rails so that my controllers can still access it. I’m not too sure what the best way is to do this. By the way I’m a Ruby on Rails newb, so perhaps what I’m asking is extremely simple.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Check this out http://railscasts.com/episodes/164-cron-in-ruby (there is a revised version, but you have to pay $9 aprox. per month for pro videos).
You can make a task or a runner so you can access to ActiveRecord and store the data into some model.
For runners in Rails: http://guides.rubyonrails.org/command_line.html#rails-runner
For tasks: http://erik.debill.org/2011/12/04/rake-for-rails-developers
Also, if you use tasks (which I recommend) watch this entry: Do rails rake tasks provide access to ActiveRecord models?