aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/test/models/tag.rb
blob: b48b9a2155eaa3b4bf2355f95ea5a88d86aa5e0a (plain) (tree)
1
2
3
4
5
6
7
                              
                    
                                            
                   
 

                                                                                              





                                                                             
class Tag < ActiveRecord::Base
  has_many :taggings
  has_many :taggables, :through => :taggings
  has_one  :tagging

  has_many :tagged_posts, :through => :taggings, :source => 'taggable', :source_type => 'Post'
end

class OrderedTag < Tag
  self.table_name = "tags"

  has_many :taggings, -> { order('taggings.id DESC') }, foreign_key: 'tag_id'
end