4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/active_press/taxonomy.rb', line 4
def self.included(base)
base.instance_eval do
set_table_name "wp_term_taxonomy"
set_primary_key "term_taxonomy_id"
belongs_to :term, :foreign_key => "term_id"
has_many :term_relationships, :foreign_key => "term_taxonomy_id"
has_many :posts, :through => :term_relationships
delegate :name, :to => :term
delegate :slug, :to => :term
def self.find_by_slug!(slug)
joins(:term).where('wp_terms.slug = ?', slug).first
end
end
end
|