diff options
Diffstat (limited to 'activerecord/test/models/post.rb')
| -rw-r--r-- | activerecord/test/models/post.rb | 9 | 
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 5f01ab0a82..256b720c9a 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -41,6 +41,7 @@ class Post < ActiveRecord::Base    scope :with_tags, -> { preload(:taggings) }    scope :tagged_with, ->(id) { joins(:taggings).where(taggings: { tag_id: id }) } +  scope :tagged_with_comment, ->(comment) { joins(:taggings).where(taggings: { comment: comment }) }    has_many   :comments do      def find_most_recent @@ -88,7 +89,7 @@ class Post < ActiveRecord::Base    has_and_belongs_to_many :categories    has_and_belongs_to_many :special_categories, :join_table => "categories_posts", :association_foreign_key => 'category_id' -  has_many :taggings, :as => :taggable +  has_many :taggings, :as => :taggable, :counter_cache => :tags_count    has_many :tags, :through => :taggings do      def add_joins_and_select        select('tags.*, authors.id as author_id') @@ -217,3 +218,9 @@ class PostThatLoadsCommentsInAnAfterSaveHook < ActiveRecord::Base      post.comments.load    end  end + +class PostWithCommentWithDefaultScopeReferencesAssociation < ActiveRecord::Base +  self.table_name = 'posts' +  has_many :comment_with_default_scope_references_associations, foreign_key: :post_id +  has_one :first_comment, class_name: "CommentWithDefaultScopeReferencesAssociation", foreign_key: :post_id +end  | 
