Answer the question
In order to leave comments, you need to log in
Globalize gem + SQL, how to get field value without calling gem methods?
I use the Globalize gem for multilingualism.
There are many heavy queries that end up being written in pure SQL.
Model:
class Page < ActiveRecord::Base
translates :h1, :title, :content
end
page = Page.first # запрос на получение страницы
page.title # тут произойдет еще один запрос в таблицу page_translates для получения переводов для текущей локали
SELECT * FROM pages p JOIN page_translations pt ON pt.page_id = p.id LIMIT 1
sql_page.title
sql_page.read_attribute(:title)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question