[Confirmation]
It was confirmed by script/console command that ActiveRecord::Base
connection is used.
The log was shown in the following:
$ ruby script/console
>> ActiveRecord::Base.active_connections.keys
=> []
>> Slave::User.find :first
=> (snip)
>> ActiveRecord::Base.active_connections.keys
=> ["ActiveRecord::Base"]
>> Slave::User.find :first
=> (snip)
>> ActiveRecord::Base.active_connections.keys
=> ["ActiveRecord::Base",Slave]
The MMC module is just defined in the tail of enviroment.rb
require "magic_multi_connections"
module Slave
establish_connection :slave1
end
[Suggestion]
To comment out Line 7 in magic_multi_connections-1.0.0/lib/
magic_multi_connections/connected.rb
#return pre_connected_const_missing(const_id) rescue nil
After the fix was applyed, even at the first time the connection
specificated in the module. By now we have no trouble due to this fix,
the fix might occur some troubles...
Please give us some advices if you have better ideas.
[Environment]
ruby : ruby 1.8.5 (2006-08-25) [i686-linux]
mysql: 5.0.27-standard
rails: 1.2.3
mmc: 1.0.0
#return pre_connected_const_missing (const_id) rescue nil
After the fix was applyed, even at the first time the connection
specificated in the module. By now we have no trouble due to this fix,
the fix might occur some troubles...
Please give us some advices if you have better ideas.
[Environment]
ruby : ruby 1.8.5 (2006-08-25) [i686-linux]
mysql: 5.0.27-standard
rails: 1.2.3
mmc: 1.0.0
Thanks
Blake
> > #return pre_connected_const_missing(const_id) rescue nil
>
> > After the fix was applyed, even at the first time the connection
> > specificated in the module. By now we have no trouble due to this fix,
> > the fix might occur some troubles...
> > Please give us some advices if you have better ideas.
>
> > [Environment]
> > ruby : ruby 1.8.5 (2006-08-25) [i686-linux]
> > mysql: 5.0.27-standard
> > rails: 1.2.3
> > mmc: 1.0.0
>
> --
> Dr Nic Williamshttp://myconfplan.com- plan the next conference you go tohttp://www.drnicwilliams.com- Ruby/Rails/Javascript/Web2.0
> skype: nicwilliams
> (p) +61 7 3102 3237 (Finds me anywhere in the world, via Skype)
> (m) +4673 681 5093 (Swedish mobile)
> (f) +61 7 3305 7572 (sends fax to my email)
> Bj rnsonsgatan 153, 16 844 Bromma, Sweden
http://drnicacademy.com - Ruby/Rails training around the world
http://drnicwilliams.com - Ruby/Rails/Javascript/Web2.0
skype: nicwilliams
(p) +61 7 3102 3237 (Finds me anywhere in the world, via Skype)
(m) +4673 681 5093 (Swedish mobile)
(f) +61 7 3305 7572 (sends fax to my email)
Fleminggatan 25, 112 26 Stockholm, Sweden
Module::MyClass1.find(:all) #=> works as expected
Module::MyClass2.find(:all) #=> works as expected
Module::MyClass3.find(:all) #=> does not work -- uses the production
connection
However, the following does work:
Module::MyClass1.find(:all) #=> works as expected
Module::MyClass2.find(:all) #=> works as expected
Module::MyClass3
Module::MyClass3.find(:all) #=> works as expected
MyClass1, 2, and 3 are all direct descendants of ActiveRecord::Base.
Am I doing something terribly wrong? Does the above make sense? Thanks
in advance and sorry for the three posts in one day.
Erik
On Jun 21, 1:47 pm, "Nic Williams" <drnicwilli...@gmail.com> wrote:
> That's right, it creates a new class within the model's namespace, that is a
> subclass of the actual class you want. It then calls #establish_connection
> on the new class.
>
> > > Dr Nic Williamshttp://myconfplan.com-plan the next conference you go
> > tohttp://www.drnicwilliams.com-Ruby/Rails/Javascript/Web2.0
> > > skype: nicwilliams
> > > (p) +61 7 3102 3237 (Finds me anywhere in the world, via Skype)
> > > (m) +4673 681 5093 (Swedish mobile)
> > > (f) +61 7 3305 7572 (sends fax to my email)
> > > Bj rnsonsgatan 153, 16 844 Bromma, Sweden
>
> --
> Dr Nic Williamshttp://drnicacademy.com- Ruby/Rails training around the worldhttp://drnicwilliams.com- Ruby/Rails/Javascript/Web2.0
http://drnicacademy.com - Ruby/Rails training around the world
http://drnicwilliams.com - Ruby/Rails/Javascript/Web2.0
skype: nicwilliams
(p) +61 7 3102 3237 (Finds me anywhere in the world, via Skype)
(m) +4673 681 5093 (Swedish mobile)
(f) +61 7 3305 7572 (sends fax to my email)
mail) Tele2 AB, c/o Berit Bergstrom
Archimedesvagen 4, Bromma, 16866, Sweden