Sha256: 3651c791c237170742d154dc66314b7d95f3c2d1c27e92cf293fd0a056ce7ffc

Contents?: true

Size: 915 Bytes

Versions: 11

Compression:

Stored size: 915 Bytes

Contents

# DEPRECATED MODEL, NOT USED ANY MORE
module CamaleonCms
  class PostRelationship < CamaleonRecord
    self.table_name = "#{PluginRoutes.static_system_info['db_prefix']}term_relationships"
    # attr_accessible :objectid, :term_taxonomy_id, :term_order
    default_scope -> { order(term_order: :asc) }

    belongs_to :post_type, class_name: 'CamaleonCms::PostType', foreign_key: :term_taxonomy_id,
                           inverse_of: :post_relationships, required: false
    belongs_to :post, lambda {
                        order("#{CamaleonCms::Post.table_name}.id DESC")
                      }, foreign_key: :objectid, inverse_of: :post_relationships, dependent: :destroy, required: false

    # callbacks
    after_create :update_count
    before_destroy :update_count

    private

    def update_count
      post_type.update_column('count', post_type.posts.size) if post_type.present?
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
camaleon_cms-2.9.0 app/models/camaleon_cms/post_relationship.rb
camaleon_cms-2.8.3 app/models/camaleon_cms/post_relationship.rb
camaleon_cms-2.8.2 app/models/camaleon_cms/post_relationship.rb
camaleon_cms-2.8.1 app/models/camaleon_cms/post_relationship.rb
camaleon_cms-2.8.0 app/models/camaleon_cms/post_relationship.rb
camaleon_cms-2.7.5 app/models/camaleon_cms/post_relationship.rb
camaleon_cms-2.7.4 app/models/camaleon_cms/post_relationship.rb
camaleon_cms-2.7.3 app/models/camaleon_cms/post_relationship.rb
camaleon_cms-2.7.2 app/models/camaleon_cms/post_relationship.rb
camaleon_cms-2.7.1 app/models/camaleon_cms/post_relationship.rb
camaleon_cms-2.7.0 app/models/camaleon_cms/post_relationship.rb