Estelle Winterflood
2006-Feb-06 20:34 UTC
[Rails] Globalize plugin, now I have two classes with the same name
Hi, newbie here. I''m using the Globalize plugin, which defines a model with the same name as one of my existing models. We both use a model called Country. The Globalize Country model (within vendors/...) is wrapped in module like this... module Globalize class Country < ActiveRecord::Base ... end end And this is my Country model (within app/models)... class Country < ActiveRecord::Base has_many :addresses ... end I''m not sure how to deal with this situation. My country table has a couple of fields that are unique, so I want to keep this information in the database (whether it be combined with the globalize_countries table, or maintained in a separate countries table). Also, I want to define my own class/instance methods etc and obviously I want to put these in my own model, completely separate from the Globalize plugin. But currently Country.find is invoking the Globalize Country class rather than my own. Can someone explain how I can deal with this situation as cleanly as possible? TIA, Estelle.
Joshua Harvey
2006-Feb-06 21:09 UTC
[Rails] Globalize plugin, now I have two classes with the same name
Estelle, Are you doing an "include Globalize" somewhere? If you make sure that that include doesn''t appear in your code, then the Globalize Country model shouldn''t be imported into your namespace, i.e. it should work like you want it to. You will have to call the globalize classes as Globalize::Locale.set, etc. Best, Josh http://shnoo.gr http://globalize-rails.org #globalize IRC channel on freenode Estelle wrote: But currently Country.find is invoking the Globalize Country class rather than my own. Can someone explain how I can deal with this situation as cleanly as possible?
Estelle Winterflood
2006-Feb-06 22:35 UTC
[Rails] Globalize plugin, now I have two classes with the same name
Josh, Thanks - yep I did have an "include Globalize" in my env file. I''ll take it out. I was also unsure about what to do with my own country table, but I think I''ll probably just rename it (or leave it), remove the duplicate information and add a foreign key referencing the globalize_country table. The Globalize plugin is looking pretty fantastic. Thanks for all your hard work! Regards, Estelle. On 2/6/06, Joshua Harvey <jmharvey.9956003@bloglines.com> wrote:> Estelle, > > Are you doing an "include Globalize" somewhere? If you make sure that > that include doesn''t appear in your code, then the Globalize Country > model shouldn''t be imported into your namespace, i.e. it should work > like you want it to. > > You will have to call the globalize classes as Globalize::Locale.set, etc. > > Best, > Josh > http://shnoo.gr > http://globalize-rails.org > #globalize IRC channel on freenode > > Estelle wrote: > > But currently Country.find is invoking the Globalize Country class > rather than my own. > > Can someone explain how I can deal with this situation as cleanly as possible? > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >