0

I have a rails app that only allows users to search and view the contents of its (MySQL) database. To add records to the database, I'd like to run a ruby script automatically twice a day which generates the contents of the database and then updates the db. Is this possible, or does my script have to be a part of the rails web app?

1
  • Do you need to go through the app's models to do some INSERTs into MySQL or can you connect directly to the database? Commented Jun 8, 2018 at 19:33

2 Answers 2

2

Just to lead you in the right direction - you can use a Rake task for this. These are usually put in the lib/tasks directory.

It's a good idea to separate non-web related things such as seeding or updating a database. If this is a scheduled job, you can use whenever to hook the rake task to cron.

Sign up to request clarification or add additional context in comments.

Comments

0

Solved this using rails runner command

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.