Globalize2 and Finder Methods

Ruby on Rails Add comments

The discussion is here and Sam Pohlenz hit the nail on the head: to enable the ActiveRecord find method on the translated fields in your <your_model>_translations table (find_by and find_all_by probably won’t work), you will have to use the following syntax (ditto for paginate of the will_paginate plugin):

:joins => :globalize_translations,
:conditions => {:post_translations => {:title => ‘foo’, :locale => ‘en’}},
:o rder => :title

The :joins => :globalize_translations option is essential here while an :include => :post_translations won’t work, likely because Globalize2 does not create a genuine association to the translations table which ActiveRecord could use.

[Slashdot] [Digg] [Reddit] [] [Facebook] [Technorati] [Google] [StumbleUpon]

Leave a Reply