Fred, as always, you are the man. Thanks for idiot checking me!
For any searchers/googlers with the same issue:
# THIS IS WRONG
class Something < ActiveRecord::Base
ActiveRecord::Base.establish_connection("name_of_your_database_dot_yml_connection")
# ...
end
# This appears right
class Something < ActiveRecord::Base
self.establish_connection("name_of_connection_in_database_dot_yml")
# ...
end
On Mar 4, 2:32 pm, Frederick Cheung <[email protected]>
wrote:
> On Mar 4, 8:33 pm, Phoenix Rising <[email protected]> wrote:
>
> > It queries the FIRST database, the one that the CompanyJob model
> > connects to. It seems to be switching the default connection behind
> > the scenes and I'm not sure how to override that.
>
> It's switching the default connection because you're asking it to -
> you're calling establish_connection on ActiveRecord::Base. You should
> just be calling it on the class you want to change.
>
> Fred
>
>
>
>
>
> > I tried manually assigning the ActiveRecord connection for the right
> > database to the Job model, but it still exhibits this exact same
> > behavior.
>
> > Does anyone know how I can force Rails to use the remote/other DB ONLY
> > for that specific model, regardless of the fact that both databases
> > contain identically named tables (that I'm unable to change)?
>
> > Thanks.
--
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.