1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/models/friendship.rb
Mack Earnhardt 1d6eabb677 Refactor Person/Friendship relationships to be more intuitive
PR #5210 added a Friendship model to illustrate a bug, but in doing so
created a confusing structure because both belongs_to declarations in
Friendship referred to the same side of the join. The new structure
maintains the integrity of the bug test while changing the follower
relationship to be more useful for other testing.
2013-03-17 02:11:19 -04:00

6 lines
316 B
Ruby

class Friendship < ActiveRecord::Base
belongs_to :friend, class_name: 'Person'
# friend_too exists to test a bug, and probably shouldn't be used elsewhere
belongs_to :friend_too, foreign_key: 'friend_id', class_name: 'Person', counter_cache: :friends_too_count
belongs_to :follower, class_name: 'Person'
end