Sha256: 293aa67003f625e6cb10b2aef2c03509ccaa992e3e5bfcbad9ceed6193acb640

Contents?: true

Size: 692 Bytes

Versions: 6

Compression:

Stored size: 692 Bytes

Contents

module Sphinx
  module Globalize
    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      def define_translated_index(*attr_names)
        klass_name = self.table_name.singularize
        translation_table_name = "#{klass_name}_translations"
        I18n.available_locales.each do |locale|
          self.define_index "#{klass_name}_#{locale}" do
            where "`#{translation_table_name}`.`locale` = '#{locale}'"
            attr_names.each do |attr|
              indexes translations(attr), :as => attr, :sortable => true
            end
          end
        end
      end
    end
  end
end
ActiveRecord::Base.send(:include,Sphinx::Globalize)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
forgeos_core-1.9.5.rc2 lib/sphinx_globalize.rb
forgeos_core-1.9.5.rc1 lib/sphinx_globalize.rb
forgeos_core-1.9.4 lib/sphinx_globalize.rb
forgeos_core-1.9.3 lib/sphinx_globalize.rb
forgeos_core-1.9.2 lib/sphinx_globalize.rb
forgeos_core-1.9.1 lib/sphinx_globalize.rb