Sha256: 6946b71e73d403eb93a05ba7ab2d962904a5ea34abbe9376b2e1c9343a57a817

Contents?: true

Size: 522 Bytes

Versions: 9

Compression:

Stored size: 522 Bytes

Contents

module HasManyTranslations
  # An extension module for the +has_many+ association with translations.
  module Translations
    # Returns all translations for given language. 
    
    def by_lang(lang)
      all(:conditions => "#{aliased_table_name}.locale_code eq '#{lang}'")
    end
    
    # def by_locale(locale)
    #      first(:conditions => { :locale => locale.to_s })
    #    end
    # 
    #    def by_locales(locales)
    #      all(:conditions => { :locale => locales.map(&:to_s) })
    #    end
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
has_many_translations-0.4.6 lib/has_many_translations/translations.rb
has_many_translations-0.4.5 lib/has_many_translations/translations.rb
has_many_translations-0.4.4 lib/has_many_translations/translations.rb
has_many_translations-0.4.3 lib/has_many_translations/translations.rb
has_many_translations-0.3.8 lib/has_many_translations/translations.rb
has_many_translations-0.3.7 lib/has_many_translations/translations.rb
has_many_translations-0.3.6 lib/has_many_translations/translations.rb
has_many_translations-0.3.4 lib/has_many_translations/translations.rb
has_many_translations-0.3.3 lib/has_many_translations/translations.rb