joshmh / globalize2

The second incarnation of Globalize for Rails
http://www.globalize-rails.org/
MIT License
364 stars 57 forks source link

Quering on a model with translated attributes #49

Open phlegx opened 13 years ago

phlegx commented 13 years ago

Hi!

How can I query a model where an attribute is translated with globalize2. I have for example this line, and the attribute name is in the country_translations table:

I18n.locale = :de
@countries = Country.scoped
@countries.where(:name => '[Some country name]')

This gives me an error: ActiveRecord::StatementInvalid (No attribute named name exists for table countries): ...

Thx

tomash commented 13 years ago

I wrote a reply in globalize3 issue you've created: https://github.com/svenfuchs/globalize3/issues#issue/34

with rails2 of course change .where to :conditions => {'table.field' => name}