Sha256: 380787ec37ed87c3ec7a1f2e6ab5bb20ab05cd1e9c84889801e2a06648986f7d

Contents?: true

Size: 554 Bytes

Versions: 2

Compression:

Stored size: 554 Bytes

Contents

require 'action_controller/base'

class ActionController::Base

  before_action :prepare_translation_cache

  # Preload the translations string for all the collections.
  # This allow to load all translation resources in only one SQL query.
  # Take in consideration this will execute the request for
  def preload_translations_for *collections
    RailsDbLocalize::TranslationCache.instance.prefetch_collections(*collections)
  end

private
  def prepare_translation_cache
    RailsDbLocalize::TranslationCache.reinit
    yield if block_given?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_db_localize-0.0.2 lib/ext/controller_ext.rb
rails_db_localize-0.0.1 lib/ext/controller_ext.rb