Forum: Ruby on Rails Current User, Database etc ..

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
34497f521724e9a2f31e78975b330ee5?d=identicon&s=25 Steve Dc (steve_dcmetro)
on 2009-06-09 16:14
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?
A91bd6cef23eb3516245a092e196c4da?d=identicon&s=25 Maurício Linhares (mauricio)
on 2009-06-09 16:20
(Received via mailing list)
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
34497f521724e9a2f31e78975b330ee5?d=identicon&s=25 Steve Dc (steve_dcmetro)
on 2009-06-09 17:26
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?
A91bd6cef23eb3516245a092e196c4da?d=identicon&s=25 Maurício Linhares (mauricio)
on 2009-06-09 18:50
(Received via mailing list)
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
This topic is locked and can not be replied to.