# What's the Right Rails Prologue for a Standalone Program

**URL:** <https://www.ruby-forum.com/t/whats-the-right-rails-prologue-for-a-standalone-program/175827>\
**Category:** Rails\
**Created:** [September 20, 2009, 11:45pm UTC](https://www.ruby-forum.com/t/whats-the-right-rails-prologue-for-a-standalone-program/175827 "2009-09-20T23:45:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddoherty03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@ddoherty03](https://www.ruby-forum.com/u/ddoherty03)\
**Post date:** [September 20, 2009, 11:45pm UTC](https://www.ruby-forum.com/t/whats-the-right-rails-prologue-for-a-standalone-program/175827/1 "2009-09-20T23:45:51Z")

</div>

I am trying to write a small program to exercise certain of my Rails  
classes without having to go through a browser.

I have a file that like this:  
########### filer\_convert.rb #################  
require File.dirname( **FILE** ) + ‘/…/…/config/boot’  
require ‘filer’

Filer.convert(10)

#########################################

I want to use it to debug the Filer.convert method inside an IDE  
(Komodo). filer.rb could be simply this:

############ filer.rb #######################  
class Filer \< ActiveRecord::Base  
end  
#########################################

I was hoping that the prelude to this file, the first two require  
statements would be enough to allow me to  
test rails classes. When I debug this, though, I get the error  
something like “undefined constant Active Record”. I suspect there is  
more that I need in the prelude to filer\_convert.rb to get the whole  
panopoly of rails functionality, but can’t figure out what it is.

What should be ‘required’ at the beginning of filer\_convert.rb to  
bring in all of rails?

Thank.

---

<div class="post-metadata">

**Author:** ![ddoherty03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@ddoherty03](https://www.ruby-forum.com/u/ddoherty03)\
**Post date:** [September 21, 2009, 6:11am UTC](https://www.ruby-forum.com/t/whats-the-right-rails-prologue-for-a-standalone-program/175827/2 "2009-09-21T06:11:38Z")

</div>

Thanks, pharrinton. That did it. I still get a strange internal  
error message when I run it under komodo, but I assume that’s  
a komodo issue.

---

<div class="post-metadata">

**Author:** ![ddoherty03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@ddoherty03](https://www.ruby-forum.com/u/ddoherty03)\
**Post date:** [September 21, 2009, 5:42am UTC](https://www.ruby-forum.com/t/whats-the-right-rails-prologue-for-a-standalone-program/175827/3 "2009-09-21T05:42:56Z")

</div>

On Sep 20, 3:55 pm, ddoherty03 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> #########################################  
> statements would be enough to allow me to  
> test rails classes. When I debug this, though, I get the error  
> something like “undefined constant Active Record”. I suspect there is  
> more that I need in the prelude to filer\_convert.rb to get the whole  
> panopoly of rails functionality, but can’t figure out what it is.
> 
> What should be ‘required’ at the beginning of filer\_convert.rb to  
> bring in all of rails?
> 
> Thank.

You need to include environment.rb, not boot.rb (boot.rb will load  
Rails itself, but not much actually happens without a defined Rails  
environmen).
