From eba76640862d071d89c846f8624d1e651d872794 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sun, 12 Dec 2010 16:35:27 +0000 Subject: Respect the default_scope on a join model when reading a through association --- activerecord/test/models/author.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/test/models/author.rb') diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index 34bfd2d881..29ee50e801 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -26,6 +26,10 @@ class Author < ActiveRecord::Base has_many :comments_with_order_and_conditions, :through => :posts, :source => :comments, :order => 'comments.body', :conditions => "comments.body like 'Thank%'" has_many :comments_with_include, :through => :posts, :source => :comments, :include => :post + has_many :first_posts + has_many :comments_on_first_posts, :through => :first_posts, :source => :comments, :order => 'posts.id desc, comments.id asc' + has_one :comment_on_first_posts, :through => :first_posts, :source => :comments, :order => 'posts.id desc, comments.id asc' + has_many :thinking_posts, :class_name => 'Post', :conditions => { :title => 'So I was thinking' }, :dependent => :delete_all has_many :welcome_posts, :class_name => 'Post', :conditions => { :title => 'Welcome to the weblog' } -- cgit v1.2.3 From 491ce5b6ce1a3af42d02efff9a2e42b1a8980553 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sun, 12 Dec 2010 17:03:41 +0000 Subject: Verify that creating a has_many through record where there is a default_scope on the join model works correctly (creates the join record with the default scope applied) --- activerecord/test/models/author.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/test/models/author.rb') diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index 29ee50e801..fd6d2b384a 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -77,6 +77,10 @@ class Author < ActiveRecord::Base has_many :categorizations has_many :categories, :through => :categorizations + has_many :special_categorizations + has_many :special_categories, :through => :special_categorizations, :source => :category + has_one :special_category, :through => :special_categorizations, :source => :category + has_many :categories_like_general, :through => :categorizations, :source => :category, :class_name => 'Category', :conditions => { :name => 'General' } has_many :categorized_posts, :through => :categorizations, :source => :post -- cgit v1.2.3 From c6db37e69b1ff07f7ad535d4752d0e6eb2d15bff Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sun, 19 Dec 2010 14:17:29 +0000 Subject: Don't allow a has_one association to go :through a collection association [#2976 state:resolved] --- activerecord/test/models/author.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activerecord/test/models/author.rb') diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index fd6d2b384a..244c5ac4f5 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -28,7 +28,9 @@ class Author < ActiveRecord::Base has_many :first_posts has_many :comments_on_first_posts, :through => :first_posts, :source => :comments, :order => 'posts.id desc, comments.id asc' - has_one :comment_on_first_posts, :through => :first_posts, :source => :comments, :order => 'posts.id desc, comments.id asc' + + has_one :first_post + has_one :comment_on_first_post, :through => :first_post, :source => :comments, :order => 'posts.id desc, comments.id asc' has_many :thinking_posts, :class_name => 'Post', :conditions => { :title => 'So I was thinking' }, :dependent => :delete_all has_many :welcome_posts, :class_name => 'Post', :conditions => { :title => 'Welcome to the weblog' } -- cgit v1.2.3 From 85683f2a79dbf81130361cb6426786cf6b0d1925 Mon Sep 17 00:00:00 2001 From: Szymon Nowak Date: Thu, 13 Aug 2009 21:18:43 +0200 Subject: Fix creation of has_many through records with custom primary_key option on belongs_to [#2990 state:resolved] --- activerecord/test/models/author.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord/test/models/author.rb') diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index 244c5ac4f5..83a6f5d926 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -78,6 +78,7 @@ class Author < ActiveRecord::Base has_many :categorizations has_many :categories, :through => :categorizations + has_many :named_categories, :through => :categorizations has_many :special_categorizations has_many :special_categories, :through => :special_categorizations, :source => :category -- cgit v1.2.3