ddoherty03
2009-Sep-20 19:55 UTC
What''s the Right Rails Prologue for a Standalone Program
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.
pharrington
2009-Sep-21 03:33 UTC
Re: What''s the Right Rails Prologue for a Standalone Program
On Sep 20, 3:55 pm, ddoherty03 <ddohert...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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.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).
ddoherty03
2009-Sep-21 04:09 UTC
Re: What''s the Right Rails Prologue for a Standalone Program
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. On Sep 20, 10:33 pm, pharrington <xenogene...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sep 20, 3:55 pm, ddoherty03 <ddohert...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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. > > 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).