# Making bootstraping faster

**URL:** <https://www.ruby-forum.com/t/making-bootstraping-faster/138960>\
**Category:** Rails\
**Created:** [May 29, 2008, 1:27pm UTC](https://www.ruby-forum.com/t/making-bootstraping-faster/138960 "2008-05-29T13:27:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@alby](https://www.ruby-forum.com/u/alby)\
**Post date:** [May 29, 2008, 1:27pm UTC](https://www.ruby-forum.com/t/making-bootstraping-faster/138960/1 "2008-05-29T13:27:09Z")

</div>

Hi.

I’m learning AcriveRecord (I’m not building web apps for now, just  
playing with the database layer).

Problem is, when I run the following code:

require ‘rubygems’  
require ‘activerecord’  
puts ‘hi’

It takes about 6 seconds. I’m using a slow computer. Now, it’s no fun  
playing when it takes so long to ‘require’ all the system.

Can I accelerate things a bit?

I know I can use some Ruby webserver and then the files are saved in  
memory compiled, but then what happens if I change my source using my  
editor? It won’t be re-loaded by the server.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![alby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@alby](https://www.ruby-forum.com/u/alby)\
**Post date:** [May 29, 2008, 7:03pm UTC](https://www.ruby-forum.com/t/making-bootstraping-faster/138960/2 "2008-05-29T19:03:17Z")

</div>

Albert S. wrote:

> Hi.
> 
> I’m learning AcriveRecord (I’m not building web apps for now, just  
> playing with the database layer).
> 
> Problem is, when I run the following code:
> 
> require ‘rubygems’  
> require ‘activerecord’  
> puts ‘hi’
> 
> It takes about 6 seconds. I’m using a slow computer. Now, it’s no fun  
> playing when it takes so long to ‘require’ all the system.
> 
> Can I accelerate things a bit?
> 
> I know I can use some Ruby webserver and then the files are saved in  
> memory compiled, but then what happens if I change my source using my  
> editor? It won’t be re-loaded by the server.
> 
> Any suggestions?

ActiveRecord is a huge library of code. It takes a while. If you are  
testing a command line sort of client, I don’t think there is a way  
around that. Rails does support code reloading, but that is not default  
ruby behaviour.

Something I have done in the past is use the load method. Like in an  
IRB prompt, I can execute a bunch of setup, then load and execute.  
Change some code, load that file and execute again.

require ‘rubygems’  
require ‘activerecord’

load(‘my\_file.rb’)  
MyFile.do\_something!

# change my\_file.rb code and save

load(‘my\_file.rb’)  
MyFile.do\_something!

You can even shorten that to one line, so you can just go back to IRB,  
and hit up arrow, enter.

load(‘my\_file.rb’); MyFile.do\_something!

This is one way that you can keep active record loaded, and only reload  
your changed code.

---

<div class="post-metadata">

**Author:** ![alby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@alby](https://www.ruby-forum.com/u/alby)\
**Post date:** [May 30, 2008, 12:28am UTC](https://www.ruby-forum.com/t/making-bootstraping-faster/138960/3 "2008-05-30T00:28:26Z")

</div>

Alex W. wrote:

> Something I have done in the past is use the load method. Like in an  
> IRB prompt, I can execute a bunch of setup, then load and execute.  
> Change some code, load that file and execute again.  
> […]  
> You can even shorten that to one line, so you can just go back to IRB,  
> and hit up arrow, enter.
> 
> load(‘my\_file.rb’); MyFile.do\_something!

Alex, thanks! This is so obvious and I didn’t think about this. You’ve  
made my day 🙂
