aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorBodaniel Jeanes <me@bjeanes.com>2010-09-26 22:17:18 +1000
committerBodaniel Jeanes <me@bjeanes.com>2010-09-26 22:25:25 +1000
commitb689834bcf2730353d066277f43047f10abb8d30 (patch)
tree034aff3a33977cdb529ee70b0a45297b119582ca /activerecord/test/models
parent14d2feeeab44d0161b3014c9e19f4e336c09c78e (diff)
downloadrails-b689834bcf2730353d066277f43047f10abb8d30.tar.gz
rails-b689834bcf2730353d066277f43047f10abb8d30.tar.bz2
rails-b689834bcf2730353d066277f43047f10abb8d30.zip
Initial nested_has_many_through support [#1152]
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/author.rb14
-rw-r--r--activerecord/test/models/book.rb2
2 files changed, 12 insertions, 4 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb
index 34bfd2d881..94810e2f34 100644
--- a/activerecord/test/models/author.rb
+++ b/activerecord/test/models/author.rb
@@ -83,14 +83,20 @@ class Author < ActiveRecord::Base
has_many :author_favorites
has_many :favorite_authors, :through => :author_favorites, :order => 'name'
- has_many :tagging, :through => :posts # through polymorphic has_one
- has_many :taggings, :through => :posts, :source => :taggings # through polymorphic has_many
- has_many :tags, :through => :posts # through has_many :through
+ has_many :tagging, :through => :posts # through polymorphic has_one
+ has_many :taggings, :through => :posts, :source => :taggings # through polymorphic has_many
+ has_many :tags, :through => :posts # through has_many :through (on source reflection + polymorphic)
+ has_many :distinct_tags, :through => :posts, :source => :tags, :select => "DISTINCT tags.*", :order => "tags.name"
has_many :post_categories, :through => :posts, :source => :categories
+ has_many :books
+ has_many :subscriptions, :through => :books
+ has_many :subscribers, :through => :subscriptions # through has_many :through (on through reflection)
+ has_many :distinct_subscribers, :through => :subscriptions, :source => :subscriber, :select => "DISTINCT subscribers.*", :order => "subscribers.nick"
+
has_one :essay, :primary_key => :name, :as => :writer
- belongs_to :author_address, :dependent => :destroy
+ belongs_to :author_address, :dependent => :destroy
belongs_to :author_address_extra, :dependent => :delete, :class_name => "AuthorAddress"
scope :relation_include_posts, includes(:posts)
diff --git a/activerecord/test/models/book.rb b/activerecord/test/models/book.rb
index 1e030b4f59..d27d0af77c 100644
--- a/activerecord/test/models/book.rb
+++ b/activerecord/test/models/book.rb
@@ -1,4 +1,6 @@
class Book < ActiveRecord::Base
+ has_many :authors
+
has_many :citations, :foreign_key => 'book1_id'
has_many :references, :through => :citations, :source => :reference_of, :uniq => true