Adam C. Greenfield on 20 Feb 2006 07:00:58 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PhillyOnRails] Initialize ActiveRecord w/o a database.


On 2/20/06, Adam C. Greenfield <adam.greenfield@gmail.com> wrote:
> On 2/19/06, Cassius Rosenthal <cassius@xmodulation.com> wrote:
> > Taken out of context, my question doesn't sound so complicated.  The
> > question revolves around how to initialize ActiveRecord, not the
> > connection.  From my previous post:
> > > I tried leaving 'database.yml' blank and I tried disabling
> > > ActiveRecord's initialization.  Both cause runtime errors in the app,
> > > as it tries to cache relationships I guess.
> > Yes; I would like to establish a new connection using
> > "ActiveRecord::Base#establish_connection."  I can't, because the entire
> > stack dies first, because ActiveRecord is trying to connect to
> > 'config/database.yml.'

Looking at the code in railties, there does not appear to be any
method you can configure rails not to try to connect to the database
in database.yml. You could either replace
Rails::Initializer#initialize_database
(railties/lib/initializer.rb:167 in trunk) with a dummy method (which
could possibly create other issues, I'd have to look into it further)
or just configure a sqlite database or a mysql test database in your
database.yml and deal with changing it during run time.
_______________________________________________
talk mailing list
talk@phillyonrails.org
http://lists.phillyonrails.org/mailman/listinfo/talk