Database connection per model.

I've built database authentication into my app, however once they're authenticated all their actions are done under the default user account setup in database.yml. I would like to establish a database connection in each model (so that all actions can be audited under the users' database accounts). My hang-up is trying to pass the session username and password into the establish_connection call. I know the model can't access session parameters, so was wondering if there's another way. I know establishing database connection in the code isn't best any other suggestions to accomplish this are also welcome. Thanks in advance.

Maybe I'm being thick here, but why _can't_ session parameters available in the controller be sent to the model to establish the connection?

I had models that have to change the database connection, depending on parameters passed to the controller action, so I'm mystified why that can't happen for you! Mind you, sessions are something I have yet to tackle properly!


Allan wrote: