From: Jeremy Kemper Date: 2006-10-14T14:43:23+09:00 Subject: Re: Basic ActiveRecord Usage ------=_Part_40544_11540183.1160804600244 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/13/06, jotto wrote: > > I want to run a Ruby script outside of Rails and still use Active > Record. This is what I'm trying but I am getting a "const_missing" > error - do I need to reference the connection in the printlisting > method?: > > require 'rubygems' > require 'active_record' > > class TheMode < ActiveRecord::Base > def initialize > end > > def printlisting > ActiveRecord::Base.establish_connection(:adapter => "mysql", :host => > "localhost", :username => "root", :password => "root", :database => > "commentstable") > listing = Comment.find(:all) > puts listing.text > end > > temp = TheMode.new > temp.modemaker require 'comment' Rails autoloads constants in lib, app/models, etc. When you use Active Record on its own, you need to handle that yourself. Best, jeremy ------=_Part_40544_11540183.1160804600244--