Globalize_countries conflict


#1

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


#2

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 W. 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


#3

Ingo W. 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.


#4

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 H. wrote:

Ingo W. 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.