How do I run a ruby script, that I put in my /lib/tasks/ directory in my Rails app, once?

Posted by marcamillion on Stack Overflow See other posts from Stack Overflow or by marcamillion
Published on 2012-06-02T22:29:26Z Indexed on 2012/06/02 22:40 UTC
Read the original article Hit count: 427

Eventually I would like to get to setting it up as a Rake task and do a cron job, but for right now...all I want to do is take my ruby script that used to work as a standalone script and have it work within my Rails app.

I renamed the file to be .rake instead of .rb and tried doing rake my_script at the command-line, but that gave me this error message:

rake aborted!
Don't know how to build task 'my_script'

(See full trace by running task with --trace)

How do I run this script within my Rails environment?

This is the first time I am doing something like this, so any assistance would be greatly appreciated.

Thanks.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby