【发布时间】:2013-01-22 01:22:03
【问题描述】:
我有两个类具有以下关系/方法:
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 时,我如何知道是哪个 Foo 从 bar_method 中调用了它?这可能吗?
谢谢
【问题讨论】:
标签: ruby-on-rails ruby has-many relationships