Class: Globalize::ActiveRecord::Translation
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Globalize::ActiveRecord::Translation
- Defined in:
- lib/globalize/active_record/translation.rb
Class Method Summary collapse
- .translated_locales ⇒ Object
- .with_locales(*locales) ⇒ Object (also: with_locale)
Instance Method Summary collapse
Class Method Details
.translated_locales ⇒ Object
15 16 17 |
# File 'lib/globalize/active_record/translation.rb', line 15 def translated_locales select('DISTINCT locale').map(&:locale) end |
.with_locales(*locales) ⇒ Object Also known as: with_locale
7 8 9 10 11 12 |
# File 'lib/globalize/active_record/translation.rb', line 7 def with_locales(*locales) # Avoid using "IN" with SQL queries when only using one locale. locales = locales.flatten.map(&:to_s) locales = locales.first if locales.one? where(:locale => locales) end |
Instance Method Details
#locale ⇒ Object
20 21 22 |
# File 'lib/globalize/active_record/translation.rb', line 20 def locale read_attribute(:locale).to_sym end |
#locale=(locale) ⇒ Object
24 25 26 |
# File 'lib/globalize/active_record/translation.rb', line 24 def locale=(locale) write_attribute(:locale, locale.to_s) end |