Sha256: 96d335ee58a88ae26498b36506b1ebb896fc665eba8332c46b514ace55319c4e

Contents?: true

Size: 510 Bytes

Versions: 1

Compression:

Stored size: 510 Bytes

Contents

require 'active_record'

module Wptools
  class WpTermTaxnomy < ActiveRecord::Base
    self.table_name = 'wp_term_taxonomy'
    has_many :wp_terms, foreign_key: :term_id
    has_many :wp_term_relationships, foreign_key: :term_taxonomy_id
    has_many :wp_posts, through: :wp_term_relationships

    scope :tags, -> { where(taxonomy: 'post_tag') }
    scope :categories, -> { where(taxonomy: 'category') }

    def list
      wp_terms.map { |wp_term| { wp_term.slug => wp_term.name } }.flatten
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wptools-0.1.0 lib/wptools/wp_term_taxnomy.rb