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