module HstoreTranslations::AccessMethods::ClassMethods
Public Instance Methods
order_by_translated(arg, locale = HstoreTranslations.locale)
click to toggle source
# File lib/hstore_translations/access_methods.rb, line 21 def order_by_translated(arg, locale = HstoreTranslations.locale) name, mode = if arg.is_a?(Hash) [arg.keys.first, arg.values.first] else [arg, :asc] end order("#{table_name}.#{name}_translations->'#{locale}' #{mode}") end
with_translated(name, value, locales = HstoreTranslations.fallbacks)
click to toggle source
# File lib/hstore_translations/access_methods.rb, line 14 def with_translated(name, value, locales = HstoreTranslations.fallbacks) hstore_query_parts = Array(locales).map do |locale| "#{table_name}.#{name}_translations @> '#{locale}=>#{value}'" end where(hstore_query_parts.join(' OR ')) end