lib/has_translations.rb in has_translations-0.3.0 vs lib/has_translations.rb in has_translations-0.3.1

- old
+ new

@@ -138,15 +138,20 @@ translation_class.belongs_to belongs_to translation_class.validates_presence_of :locale translation_class.validates_uniqueness_of :locale, :scope => :"#{belongs_to}_id" - named_scope :translated, lambda { |locale| {:conditions => ["#{translation_class.table_name}.locale = ?", locale.to_s], :joins => :translations} } + # Rails 3.0 + if Object.const_defined?("ActiveModel") + scope :translated, lambda { |locale| {:conditions => ["#{translation_class.table_name}.locale = ?", locale.to_s], :joins => :translations} } + else + named_scope :translated, lambda { |locale| {:conditions => ["#{translation_class.table_name}.locale = ?", locale.to_s], :joins => :translations} } + end private def find_translation(locale) locale = locale.to_s translations.detect { |t| t.locale == locale } end end -end \ No newline at end of file +end