In database.yml:

your_environment:
  adapter:  your_adapter
  database: your_database
  user:     your_user
  ...

a_name_for_your_other_database_connection:
  # your connection information here: adapter, etc.

In your models for the other database:

class YourClassName < YourOtherDatabaseConnectionName # what you named
your other DB connection in database.yml

With the above you wouldn't need to specify the DB and table names in
your models but the class definition would contain the connection the
model belongs to.


On Apr 14, 3:00 am, anton effendi <[email protected]> wrote:
> hmmmm
> u read about establish_connection on active record....
>
> may be it will help u....
>
> Thank you...
>
>
>
> On Wed, Apr 14, 2010 at 12:43 PM, tispratik <[email protected]> wrote:
> > Thanks for the quick reply Philip.
> > Unfortunately i am working on a windows machine and i am not aware of
> > any tool which shows the query being run.
> > An interesting workaround i found is by explicitly stating the
> > database.table_name in the intermediate model.
>
> > class ProjectRole < ActiveRecord::Base
> >    set_table_name 'Y.project_roles'
> > end
>
> > Seems like when i do user.projects, rails assumes that the
> > project_roles table is in the latter model's database (which is true)
> > so it works.
> > But when i do, project.users, rails looks for project_roles table in
> > the database where users table is located (which is incorrect), so it
> > dosent.
> > But this dosent seem to be a good workaround as i have to hardcode the
> > database.table_name in the model class.
>
> > -Regards,
> > Pratik
>
> > --
> > 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 [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<rubyonrails-talk%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> --
>
> Senior Rails Developer
> Anton Effendi - Wu You Duan

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to