diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-10-19 12:47:19 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2010-10-19 12:47:19 +0100 |
commit | 596cc3b2329a9cc4a30c95c157ce36b2d08975df (patch) | |
tree | 2a67f6a9270bb528ad5df8bc805f2ef121e93858 /activerecord/test/models | |
parent | 9ec07348749675110843c44f680da79223218db2 (diff) | |
download | rails-596cc3b2329a9cc4a30c95c157ce36b2d08975df.tar.gz rails-596cc3b2329a9cc4a30c95c157ce36b2d08975df.tar.bz2 rails-596cc3b2329a9cc4a30c95c157ce36b2d08975df.zip |
Respect the :primary_key option on the through_reflection of (non-nested) through associations
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/author.rb | 12 | ||||
-rw-r--r-- | activerecord/test/models/essay.rb | 1 |
2 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index c0e082836d..1ba01d6b6b 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -95,8 +95,18 @@ class Author < ActiveRecord::Base has_many :subscriptions, :through => :books has_many :subscribers, :through => :subscriptions, :order => "subscribers.nick" # 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 + has_one :essay_category, :through => :essay, :source => :category + + 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 :essays_2, :primary_key => :name, :class_name => 'Essay', :foreign_key => :author_id + has_many :essay_categories_2, :through => :essays_2, :source => :category belongs_to :author_address, :dependent => :destroy belongs_to :author_address_extra, :dependent => :delete, :class_name => "AuthorAddress" diff --git a/activerecord/test/models/essay.rb b/activerecord/test/models/essay.rb index 6c28f5e49b..6a62042863 100644 --- a/activerecord/test/models/essay.rb +++ b/activerecord/test/models/essay.rb @@ -1,3 +1,4 @@ class Essay < ActiveRecord::Base belongs_to :writer, :primary_key => :name, :polymorphic => true + belongs_to :category end |