Ruby Forum Rails I18n > globalize_countries conflict

Posted by Ingo Weiss (ingoweiss)
on 02.02.2007 05:32
Hi,

I just installed globalize and the problem is that I have a model
'Country' which seems to conflict with globalize's 'Globalize::Country'
model. Every time I use 'Country' now Rails assumes I mean
Globalize::Country. How can I work around that?

Thanks!
Ingo
Posted by Ingo Weiss (ingoweiss)
on 03.02.2007 03:06
Thanks for the reply! I got my app working by wrapping my Country model 
in a module like this MyApp::Country, and replacing all references to 
Country with MyApp::Country.

The only problem right now is that almost all my functional tests broke, 
I think because when I use the generated functions to load models from 
fixtures like 'countries(:us)', Rails tries to load it from 
Globalize::Countries. How can I tell Rails to use MyApp::Country in 
these functions, too?

Thanks!
Ingo





Ingo Weiss wrote:
> Hi,
> 
> I just installed globalize and the problem is that I have a model
> 'Country' which seems to conflict with globalize's 'Globalize::Country'
> model. Every time I use 'Country' now Rails assumes I mean
> Globalize::Country. How can I work around that?
> 
> Thanks!
> Ingo
Posted by Philipp Hofmann (phil)
on 01.08.2007 23:41
Ingo Weiss wrote:
> Thanks for the reply! I got my app working by wrapping my Country model 
> in a module like this MyApp::Country, and replacing all references to 
> Country with MyApp::Country.

Hi,

I am experiencing the same problem and havn't figured out yet how to 
point a *belongs_to* to the *moduled* model.

The obvious approach ...

 module MyApp
   class Country < ActiveRecord::Base
   end
 end

 class Person
   belongs_to :country, :class_name => 'MyApp::Country'
 end

... sadly doesn't work.
Posted by Ben Wyrosdick (bwyrosdick)
on 29.11.2007 08:09
I had the same problem ... I fixed it without wrapping my model in a 
module.

http://blog.commonthread.com/2007/11/28/globalize-hijacked-my-country


Philipp Hofmann wrote:
> Ingo Weiss wrote:
>> Thanks for the reply! I got my app working by wrapping my Country model 
>> in a module like this MyApp::Country, and replacing all references to 
>> Country with MyApp::Country.
> 
> Hi,
> 
> I am experiencing the same problem and havn't figured out yet how to 
> point a *belongs_to* to the *moduled* model.
> 
> The obvious approach ...
> 
>  module MyApp
>    class Country < ActiveRecord::Base
>    end
>  end
> 
>  class Person
>    belongs_to :country, :class_name => 'MyApp::Country'
>  end
> 
> ... sadly doesn't work.