Forum: Rails I18n globalize_countries conflict

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3504745159d79c585e4f7df8df76aa10?d=identicon&s=25 Ingo Weiss (ingoweiss)
on 2007-02-02 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
3504745159d79c585e4f7df8df76aa10?d=identicon&s=25 Ingo Weiss (ingoweiss)
on 2007-02-03 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
1c290a21ca0bb678e9f4f1006a13595e?d=identicon&s=25 Philipp Hofmann (phil)
on 2007-08-01 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.
5fde02269fa53e53a38a6cc286ca6bd0?d=identicon&s=25 Ben Wyrosdick (bwyrosdick)
on 2007-11-29 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-...


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.
This topic is locked and can not be replied to.