Skip to content

Instantly share code, notes, and snippets.

@weepy
Created September 16, 2009 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weepy/187951 to your computer and use it in GitHub Desktop.
Save weepy/187951 to your computer and use it in GitHub Desktop.
# why are the objects different !
class Player < ActiveRecord::Base
belongs_to :match
end
class Match < ActiveRecord::Base
has_many :players
end
>> match = Match.first
=> #<Match id: 5 ... >
>> match.players[0]
=> #<Player id: 1 ... >
>> match.players[0].match == match
=> true
>> match.players[0].match.object_id == match.object_id
=> false
>> match.players[1].match == match
=> true
>> match.players[1].match.object_id == match.object_id
=> false
>> match.players[1].match.object_id == match.players[0].match.object_id
=> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment