← Home

Disable Globalize::ViewTranslation SQL logging

module Globalize # :nodoc:
 class DbViewTranslator
   alias_method :orig_fetch_view_translation, :fetch_view_translation
   def fetch_view_translation(key, language, idx, namespace = nil)
     ActiveRecord::Base.silence do
       orig_fetch_view_translation(key, language, idx, namespace = nil)

Obviously, this wraps around the Globalize's fetch_view_translation method and uses ActiveRecord::Base#silence to prevent ActiveRecord from logging the query.

That’s handy. I've added this to the Tips & tricks installment of the Globalize series.

Thanks, Joost!

PS: ... wow, let me guess, is there a Globalize installation using subdomains for locales peeking from behind the curtains of YellowYellow?