Sha256: 4a694f0158b420956adcee0129066a0435c74c25a23093b020baa86d785407b1

Contents?: true

Size: 760 Bytes

Versions: 2

Compression:

Stored size: 760 Bytes

Contents

require 'active_support/concern'

module Georgia
  module Concerns
    module Contentable
      extend ActiveSupport::Concern

      included do
        has_many :contents, as: :contentable, dependent: :destroy, class_name: Georgia::Content
        accepts_nested_attributes_for :contents
        attr_accessible :contents_attributes

        scope :with_locale, lambda {|locale| joins(:contents).where(georgia_contents: {locale: locale}).uniq}

        def content(locale=nil)
          locale ||= I18n.locale.to_s
          @content ||= contents.select{|c| c.locale == locale}.first || Georgia::Content.new(locale: locale)
        end

				delegate :title, :text, :excerpt, :keywords, :keyword_list, :image, :locale, to: :content
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
georgia-0.7.8 app/models/georgia/concerns/contentable.rb
georgia-0.7.7 app/models/georgia/concerns/contentable.rb