Are there methods for the model object to get the current_user, and current_database? I was hoping that this would be available as methods from the connection object. For example model.connection.db_user model.connection.db_name Is there a group for ActiveRecord, where I can post this? -- Posted via http://www.ruby-forum.com/.
YourActiveRecordModel.configurations[ Rails.env ][ ''username'' ] YourActiveRecordModel.configurations[ Rails.env ][ ''database'' ] - Maurício Linhares http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr On Tue, Jun 9, 2009 at 11:14 AM, Steve Dc<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Are there methods for the model object to get the current_user, and > current_database? I was hoping that this would be available as methods > from the connection object. > > For example > model.connection.db_user > model.connection.db_name > > Is there a group for ActiveRecord, where I can post this? > -- > Posted via http://www.ruby-forum.com/. > > > >
Maurício Linhares wrote:> YourActiveRecordModel.configurations[ Rails.env ][ ''username'' ] > YourActiveRecordModel.configurations[ Rails.env ][ ''database'' ] > > - > Maur�cio Linhares > http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr > > > > On Tue, Jun 9, 2009 at 11:14 AM, SteveThanks for your suggestion. However I am spcifying a dsn which includes Username, and database. This approach has a couple of issues. 1. The user may be logging in using Windows authentication. In that case database.yml will not have a value for User field. 2. What if the application changes connection after starting up? -- Posted via http://www.ruby-forum.com/.
This is how you can get the info from an activerecord object, if you''re not using active record or if you''re using a custom made solution it obviously won''t work. - Maurício Linhares http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr On Tue, Jun 9, 2009 at 12:26 PM, Steve Dc<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Maurício Linhares wrote: >> YourActiveRecordModel.configurations[ Rails.env ][ ''username'' ] >> YourActiveRecordModel.configurations[ Rails.env ][ ''database'' ] >> >> - >> Maur�cio Linhares >> http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr >> >> >> >> On Tue, Jun 9, 2009 at 11:14 AM, Steve > > Thanks for your suggestion. However I am spcifying a dsn which includes > Username, and database. This approach has a couple of issues. > > 1. The user may be logging in using Windows authentication. In that case > database.yml will not have a value for User field. > 2. What if the application changes connection after starting up? > -- > Posted via http://www.ruby-forum.com/. > > > >