module Mobility::Backends::ActiveRecord::Table::TranslationsHasManyExtension

Public Instance Methods

destroy_empty_translations(required_attributes) click to toggle source

Destroys translations with all empty values

# File lib/mobility/backends/active_record/table.rb, line 306
def destroy_empty_translations(required_attributes)
  empty_translations = select{ |t| required_attributes.map(&t.method(:send)).none? }
  destroy(empty_translations) if empty_translations.any?
end
in_locale(locale) click to toggle source

Returns translation in a given locale, or nil if none exist @param [Symbol, String] locale

# File lib/mobility/backends/active_record/table.rb, line 300
def in_locale(locale)
  locale = locale.to_s
  find { |t| t.locale == locale }
end