Is there a way to retrieve the name of the database to which an AR class is connected? TIA Luca
Yes there is: just send table_name message to the object. Zsombor On 5/24/05, Luca Pireddu <lucap-fVOoFLC7IWo@public.gmane.org> wrote:> Is there a way to retrieve the name of the database to which an AR class is > connected? > > TIA > > Luca > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- http://deezsombor.blogspot.com
On 5/23/05, Dee Zsombor <dee.zsombor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes there is: just send table_name message to the object.Uh, wouldn''t that get the name of the table? And not the database?> > Zsombor > > On 5/24/05, Luca Pireddu <lucap-fVOoFLC7IWo@public.gmane.org> wrote: > > Is there a way to retrieve the name of the database to which an AR class is > > connected? > > > > TIA > > > > Luca > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > http://deezsombor.blogspot.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Oops! You are right ... sorry about that. OTH if using MySql you can retrieve database name by doing "SELECT DATABASE()". Don''t know any general adapter independent rails specific way of doing the same. Zsombor On 5/24/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 5/23/05, Dee Zsombor <dee.zsombor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Yes there is: just send table_name message to the object. > > Uh, wouldn''t that get the name of the table? And not the database? > > > > > Zsombor > > > > On 5/24/05, Luca Pireddu <lucap-fVOoFLC7IWo@public.gmane.org> wrote: > > > Is there a way to retrieve the name of the database to which an AR class is > > > connected? > > > > > > TIA > > > > > > Luca > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > > http://deezsombor.blogspot.com > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- http://deezsombor.blogspot.com
On 5/24/05, Dee Zsombor <dee.zsombor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> OTH if using MySql you can retrieve database name by doing "SELECT > DATABASE()". Don''t know any general adapter independent rails specific > way of doing the same.This is how it is done in the Rake file... abcs = ActiveRecord::Base.configurations abcs[RAILS_ENV]["database"]