ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-rails
ruby-rails
[Rails] When is database.yml loaded with FCGI?
by Just Someone other posts by this author
Dec 4 2005 1:45PM messages near this date
Re: [Rails] unit testing and the schema | Re: [Rails] When is database.yml loaded with FCGI?
I'm trying to implement a Postgres based Rails system with multiple
schemas (one per user for security).

For that I need to set a different login user for each of the
connecting users (based on a central authentication system that sets
the login to the session info). SO I need to login as a different user
for each connection coming in.

1) When running a Rails app through FCGI/SCGI, is the database.yml
file loaded only when one of the runners launches, or on every
request?

2) Can I change database.yml so that when it's read with erb it'll
replace the user with something from the session automatically?

In other words, lets say my database.yml looks like:
production:
  adapter: postgresql
  database: myapp_production
  host: localhost
  username: <%= session[:db_user] %> 
  password: <%= session[:db_pass] %> 

1) Will this even work?
2) Will it change with each connection?
3) If not, where should I call establish_connection() when a session
starts, so that I can assign the user I want to?

Once I have this figured out I'll write a short wiki page on how to
use postgres schemas to insulate one user from the other, while not
messing with all the rails way of doing things.

Bye,

Guy.
_______________________________________________
Rails mailing list
Rails@[...].org
http://lists.rubyonrails.org/mailman/listinfo/rails
Thread:
Just Someone
Ara T Howard
Just Someone

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved