Sha256: 8171229eea0aea18399efe2fc5e1bf69e5361f582854ad4275e4f5636a0d2bd3
Contents?: true
Size: 1.17 KB
Versions: 7
Compression:
Stored size: 1.17 KB
Contents
# +------------------+---------------------+------+-----+---------+-------+ # | Field | Type | Null | Key | Default | Extra | # +------------------+---------------------+------+-----+---------+-------+ # | object_id | bigint(20) unsigned | NO | PRI | 0 | | # | term_taxonomy_id | bigint(20) unsigned | NO | PRI | 0 | | # | term_order | int(11) | NO | | 0 | | # +------------------+---------------------+------+-----+---------+-------+ module Wordpress class Relationship < WpBase self.table_name = "wp_term_relationships" self.primary_key = nil after_save :increment_term_use_count before_destroy :decrement_term_use_count belongs_to :post, class_name: "Wordpress::Post", foreign_key: "object_id" belongs_to :taxonomy, class_name: "Wordpress::Taxonomy", foreign_key: "term_taxonomy_id" def increment_term_use_count self.taxonomy.update_attribute(:count, self.taxonomy.count + 1) if self.taxonomy.present? end def decrement_term_use_count self.taxonomy.update_attribute(:count, self.taxonomy.count - 1) if self.taxonomy.present? end end end
Version data entries
7 entries across 7 versions & 1 rubygems