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 practice...so any other suggestions to accomplish this are also welcome. Thanks in advance. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 1, 8:48 pm, Brian Penrose <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I know the model can''t > access session parameters, so was wondering if there''s another way.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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Allan wrote:> On Feb 1, 8:48 pm, Brian Penrose <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> I know the model can''t >> access session parameters, so was wondering if there''s another way. > > 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! > > AllanWork around....http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/ -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---