# Access to calling chain associations

**URL:** <https://www.ruby-forum.com/t/access-to-calling-chain-associations/178179>\
**Category:** Rails\
**Created:** [October 30, 2009, 8:04am UTC](https://www.ruby-forum.com/t/access-to-calling-chain-associations/178179 "2009-10-30T08:04:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@jakew](https://www.ruby-forum.com/u/jakew)\
**Post date:** [October 30, 2009, 8:04am UTC](https://www.ruby-forum.com/t/access-to-calling-chain-associations/178179/1 "2009-10-30T08:04:25Z")

</div>

Assuming that we have a player model and a game model and that each game  
has multiple players as described below.

class Game \< ActiveRecord::Base  
has\_many :players

def some\_method  
#  
# which player called me?  
#  
end

end

class Player \< ActiveRecord::Base  
belongs\_to :game  
end

Is there a way to determine which player called some\_method in the game  
when called through one of the players and without explicitly adding the  
player to the argument list? For example …

Player.find(id).game.some\_method();

Thanks

---

<div class="post-metadata">

**Author:** ![jakew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@jakew](https://www.ruby-forum.com/u/jakew)\
**Post date:** [October 30, 2009, 10:25am UTC](https://www.ruby-forum.com/t/access-to-calling-chain-associations/178179/2 "2009-10-30T10:25:09Z")

</div>

On Oct 30, 7:04 am, Jake We [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> end
> 
> Player.find(id).game.some\_method();

nope (at least nothing sensible I can think of). ‘Which player called  
me’ might not even be defined (eg if you do Game.find  
(123).some\_method.

Fred
