Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Dave Faliskie
Dave Faliskie
17,793 Points

How to automate a "daily post" to a rails site

Hi All,

I have a site built using ruby on rails (http://www.projectmind.guru). Basically what I am trying to do is have a "daily question" asked on the site each day. I have a list of questions in a database I need to figure out how automate the site to post one question a day from the database. The site is hosted through Heroku and I looked into using scheduler. Does anyone have any experience doing something like this I don't know if that would be the best solution.

Any Help would be great!

1 Answer

Kevin Korte
Kevin Korte
28,149 Points

You have the right idea. I used this gem in a rails app to run a cron job at midnight, on a micro app I manage, and it has worked well and reliably.

You'd just have to write the code to randomize your query for a question, and than post that question.

https://github.com/jmettraux/rufus-scheduler