On Oct 30, 7:04 am, Jake We
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> 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();
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>
> Thanks
> --
> Posted viahttp://www.ruby-forum.com/.