次の関係/メソッドを持つ2つのクラスがあります。
class Bar
has_many :foos
def bar_method
#puts the specific foo that called it
end
end
class Foo
belongs_to :bar
def foo_method
bar.bar_method
end
end
Foo のインスタンスで foo_method を呼び出す場合、bar_method 内からどの Foo がこれを呼び出したかをどのように判断できますか? これは可能ですか?
ありがとう