I’m starting using rails for a project where the SQLite database to use
depend on the SERVER_NAME contacted during the request. As I can’t use
database.yml because the dbfile is dynamic, I declare my ActiveRecords
objects in application.rb and I establish_connection manually. But now
that I saw the screencast about migration, I know that I’ll need this
because when I’ll have to add a field in my database objects, I’ll have
to do it to a bunch of SQLite databases with important data inside.
So my question is : what is the clean RoR way to use more than one
database and one of them should be dynamically selected with the
I’ve got another question : as a fcgi process can serve more than one
request, I would like to know if Rails keep the connection to the
database for all the requests or if it opens and closes the
connection(s) at each request. If it keeps the connection, how can I
make Rails close connections for each request ? Not sure if it’s
relevant for SQLite.
I just finished creating a simple class (LDAP::Auth) which enables
authentication and querying against an LDAP server. Please see the
sample/code comments for usage information.
ldap-auth is available here:
A little background…
I write and maintain several rails apps which are used all over my
organization. All of the apps require login and authentication and
controller/action level access control.
We have an LDAP server (MS ActiveDirectory) which contains all the info
need to authenticate and authorize users.
- It has all the demographic data I need like the user’s full name.
- It has all the contact info I need like the users email address.
- It even has group info, which I can use to determine which parts of my
application, if any, the user can access!
Now, my user/account tables do not contain passwords and all logins are
performed against the LDAP server. Upon a successful login, I retrieve
the user data I need from LDAP and update the user/account record in my
application’s database. For example, my applications need to know the
full name and email address, so I pull those attributes from LDAP and
the user record when the user logs in. That way my user info is always
up-to-date and changes as the LDAP data changes. I also control access
the app by examining LDAP groups the user is a member of.
On Nov 29, 5:30 pm, Vince P. [email protected] wrote:
Please don’t hijack threads !