# Initialize function for Application

**URL:** <https://www.ruby-forum.com/t/initialize-function-for-application/131127>\
**Category:** Rails\
**Created:** [March 6, 2008, 9:12am UTC](https://www.ruby-forum.com/t/initialize-function-for-application/131127 "2008-03-06T09:12:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [March 6, 2008, 9:12am UTC](https://www.ruby-forum.com/t/initialize-function-for-application/131127/1 "2008-03-06T09:12:05Z")

</div>

Hi,

I have to write a initialize function , which should be called on the  
startup of the rails application and only once during the startup.

This function creates a graph adding edges read from database.(I ahve  
code written for this). Wondering what is the right point to populate  
graph in the memory by calling this function.

Regards,  
Sandeep G

---

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [March 6, 2008, 12:17pm UTC](https://www.ruby-forum.com/t/initialize-function-for-application/131127/2 "2008-03-06T12:17:52Z")

</div>

Sandeep G. wrote:

> I have to write a initialize function , which should be called on the  
> startup of the rails application and only once during the startup.

You could call it from config/environment.rb but don’t put all the code  
in there. Put the code elsewhere and call into it.
