MailingList


Globalize 2: is it possible to search on translated fields ?

by Gianluca Tessarolo :: Rate this Message:

Reply to Author | View in Thread

Hi to all the crew,

I'm starting a new project and I want to use Globalize 2 for model
translations.

I cannot find a solution for searching on translated columns: ex.

script/generate model Article published:boolean

Article model: translates :title, :text

and then: Article.create_translation_table! :title => :string, :text =>
:text

How can I do a search like this ?

Article.all(:conditions => ["published and title like ?", params[:title]])

Seems that I cannot access the translations table ex.:

Article.all(:conditions => ["articles.published and article_translations
title like ?", params[:title]])

Seems that I cannot include translations asociations ex.:

Article.all(:iclude => article_translations, :conditions =>
["articles.published and article_translations title like ?",
params[:title]])

Is it possible to search on translated fields under Globalize2 plugin ?

Many thanks in advance...

 « Return to Thread: Is it safe to develop now, add i18n later