aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-10-19 16:13:06 +0100
committerJon Leighton <j@jonathanleighton.com>2010-10-19 16:13:06 +0100
commit915ea5ea826d48107e4c1953c7a32cf26727d10e (patch)
tree6d9c1284df9ac076d2b083737374f6b884f7197b /activerecord/test/models
parent0ceb34295501a797c9e549c581ecee17f837f01c (diff)
downloadrails-915ea5ea826d48107e4c1953c7a32cf26727d10e.tar.gz
rails-915ea5ea826d48107e4c1953c7a32cf26727d10e.tar.bz2
rails-915ea5ea826d48107e4c1953c7a32cf26727d10e.zip
Support the :primary_key option on a through reflection in a nested through association
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/author.rb3
-rw-r--r--activerecord/test/models/organization.rb8
2 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb
index 53b3b80950..dd8a20ce9b 100644
--- a/activerecord/test/models/author.rb
+++ b/activerecord/test/models/author.rb
@@ -110,6 +110,9 @@ class Author < ActiveRecord::Base
has_many :essays_2, :primary_key => :name, :class_name => 'Essay', :foreign_key => :author_id
has_many :essay_categories_2, :through => :essays_2, :source => :category
+ belongs_to :owned_essay, :primary_key => :name, :class_name => 'Essay'
+ has_one :owned_essay_category, :through => :owned_essay, :source => :category
+
belongs_to :author_address, :dependent => :destroy
belongs_to :author_address_extra, :dependent => :delete, :class_name => "AuthorAddress"
diff --git a/activerecord/test/models/organization.rb b/activerecord/test/models/organization.rb
index 1da342a0bd..c18c28c696 100644
--- a/activerecord/test/models/organization.rb
+++ b/activerecord/test/models/organization.rb
@@ -2,5 +2,11 @@ class Organization < ActiveRecord::Base
has_many :member_details
has_many :members, :through => :member_details
+ has_many :authors, :primary_key => :name
+ has_many :author_essay_categories, :through => :authors, :source => :essay_categories
+
+ has_one :author, :primary_key => :name
+ has_one :author_owned_essay_category, :through => :author, :source => :owned_essay_category
+
scope :clubs, { :from => 'clubs' }
-end \ No newline at end of file
+end