aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-08-21 14:10:33 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-08-21 14:36:04 -0300
commit648c5a1369ed64608c3ca43a5ebc917687d20010 (patch)
tree834ad77d7aec2718cb6148e6ec6cd0a42a9012fc /activerecord/test/models
parentc091fae21f32250b19475f124c3b680dbbc163d9 (diff)
downloadrails-648c5a1369ed64608c3ca43a5ebc917687d20010.tar.gz
rails-648c5a1369ed64608c3ca43a5ebc917687d20010.tar.bz2
rails-648c5a1369ed64608c3ca43a5ebc917687d20010.zip
Merge pull request #5210 from Pliny/masteri
Fix for #5200 Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/counter_cache.rb
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/friendship.rb4
-rw-r--r--activerecord/test/models/person.rb2
2 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/models/friendship.rb b/activerecord/test/models/friendship.rb
new file mode 100644
index 0000000000..6b4f7acc38
--- /dev/null
+++ b/activerecord/test/models/friendship.rb
@@ -0,0 +1,4 @@
+class Friendship < ActiveRecord::Base
+ belongs_to :friend, class_name: 'Person'
+ belongs_to :follower, foreign_key: 'friend_id', class_name: 'Person', counter_cache: :followers_count
+end
diff --git a/activerecord/test/models/person.rb b/activerecord/test/models/person.rb
index dcfea3170c..a64405b246 100644
--- a/activerecord/test/models/person.rb
+++ b/activerecord/test/models/person.rb
@@ -7,6 +7,8 @@ class Person < ActiveRecord::Base
has_many :secure_posts, :through => :secure_readers
has_many :posts_with_no_comments, :through => :readers, :source => :post, :include => :comments, :conditions => 'comments.id is null'
+ has_many :followers, foreign_key: 'friend_id', class_name: 'Friendship'
+
has_many :references
has_many :bad_references
has_many :fixed_bad_references, :conditions => { :favourite => true }, :class_name => 'BadReference'