# Script in rails

**URL:** <https://www.ruby-forum.com/t/script-in-rails/149377>\
**Category:** Rails\
**Created:** [September 24, 2008, 10:12am UTC](https://www.ruby-forum.com/t/script-in-rails/149377 "2008-09-24T10:12:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanight](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/a698b9/32.png) [@vanight](https://www.ruby-forum.com/u/vanight)\
**Post date:** [September 24, 2008, 10:12am UTC](https://www.ruby-forum.com/t/script-in-rails/149377/1 "2008-09-24T10:12:24Z")

</div>

Hi,

Can someone tell me good web links about how to use a script in rails.

Here the thing, I need to execute a script every day to generate  
reporting stuff, My script should access all data available in the  
database.

Where should I put the script so it will be able to access all models  
classes?

Can the script be executed by rails instead of calling it from the cron  
daemon?

Thanks!

---

<div class="post-metadata">

**Author:** ![vanight](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/a698b9/32.png) [@vanight](https://www.ruby-forum.com/u/vanight)\
**Post date:** [September 24, 2008, 10:19am UTC](https://www.ruby-forum.com/t/script-in-rails/149377/2 "2008-09-24T10:19:40Z")

</div>

On Sep 24, 4:12 pm, David N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Can the script be executed by rails instead of calling it from the cron  
> daemon?
> 
> ## Thanks!
> 
> Posted viahttp://www.ruby-forum.com/.

You can create a rake task for that.

> **[\#66 Custom Rake Tasks - RailsCasts](http://railscasts.com/episodes/66-custom-rake-tasks)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.
