Sha256: ee82896d5d727ec71dfb0da8502f0a6ce73bcee9d2e7b012988b7a6c382753ca
Contents?: true
Size: 1.17 KB
Versions: 16
Compression:
Stored size: 1.17 KB
Contents
module Spree module TranslatableResourceScopes extend ActiveSupport::Concern class_methods do # To be used when joining on the resource itself does not automatically join on its translations table # This method is to be used when you've already joined on the translatable table itself # # If the resource table is aliased, pass the alias to `join_on_table_alias`, otherwise omit the param def join_translation_table(translatable_class, join_on_table_alias = nil) join_on_table_name = if join_on_table_alias.nil? translatable_class.table_name else join_on_table_alias end translatable_class_foreign_key = "#{translatable_class.table_name.singularize}_id" joins("LEFT OUTER JOIN #{translatable_class::Translation.table_name} #{translatable_class.translation_table_alias} ON #{translatable_class.translation_table_alias}.#{translatable_class_foreign_key} = #{join_on_table_name}.id AND #{translatable_class.translation_table_alias}.locale = '#{Mobility.locale}'") end end end end
Version data entries
16 entries across 16 versions & 1 rubygems