aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-10-19 14:14:06 +0100
committerJon Leighton <j@jonathanleighton.com>2010-10-19 14:14:06 +0100
commit01838636c6136d9a649ace71db61bb7990f9bd82 (patch)
tree2f307e4dd6843588ab19f7d41615a04465560fff /activerecord/test/models
parent596cc3b2329a9cc4a30c95c157ce36b2d08975df (diff)
downloadrails-01838636c6136d9a649ace71db61bb7990f9bd82.tar.gz
rails-01838636c6136d9a649ace71db61bb7990f9bd82.tar.bz2
rails-01838636c6136d9a649ace71db61bb7990f9bd82.zip
Support for :primary_key option on the source reflection of a through association, where the source is a has_one or has_many
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/author.rb2
-rw-r--r--activerecord/test/models/essay.rb3
2 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb
index 1ba01d6b6b..53b3b80950 100644
--- a/activerecord/test/models/author.rb
+++ b/activerecord/test/models/author.rb
@@ -98,12 +98,14 @@ class Author < ActiveRecord::Base
has_one :essay, :primary_key => :name, :as => :writer
has_one :essay_category, :through => :essay, :source => :category
+ has_one :essay_owner, :through => :essay, :source => :owner
has_one :essay_2, :primary_key => :name, :class_name => 'Essay', :foreign_key => :author_id
has_one :essay_category_2, :through => :essay_2, :source => :category
has_many :essays, :primary_key => :name, :as => :writer
has_many :essay_categories, :through => :essays, :source => :category
+ has_many :essay_owners, :through => :essays, :source => :owner
has_many :essays_2, :primary_key => :name, :class_name => 'Essay', :foreign_key => :author_id
has_many :essay_categories_2, :through => :essays_2, :source => :category
diff --git a/activerecord/test/models/essay.rb b/activerecord/test/models/essay.rb
index 6a62042863..ec4b982b5b 100644
--- a/activerecord/test/models/essay.rb
+++ b/activerecord/test/models/essay.rb
@@ -1,4 +1,5 @@
class Essay < ActiveRecord::Base
belongs_to :writer, :primary_key => :name, :polymorphic => true
- belongs_to :category
+ belongs_to :category, :primary_key => :name
+ has_one :owner, :primary_key => :name
end