Walter Lee Davis on 20 Feb 2006 13:48:04 -0000


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

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



On Feb 20, 2006, at 1:51 AM, Adam C. Greenfield wrote:

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.


What would happen if the stack "collapsed"? (This, by the way, is a total newbie perspective, and a genuine question.) Would it be possible to have a sort of "starter" database in database.yml, and then use the user input to select a different database, kill the current process and restart with that new one?


Writing it out like this, it seems to me to be something that may either be impossible by design, or by security policy, or both, but I thought I'd mention it.

Walter

_______________________________________________
talk mailing list
talk@phillyonrails.org
http://lists.phillyonrails.org/mailman/listinfo/talk