0
我有一個架構是這樣的...ActiveRecord的嵌套關聯的多到一
class Foo < ActiveRecord::Base
has_many :bars
end
class Bar < ActiveRecord::Base
belongs_to :foo
belongs_to :bar
end
class Baz < ActiveRecord::Base
has_many :bars
end
我試圖讓所有三個對象嵌套和JSON分解,所以我有以下代碼.. 。
foo = Foo.first
foo.to_json(:include => {:bars => :baz})
但我發現了以下異常...
無法克隆符號 文件:try.rb位置:克隆行:36
我想獲得所有嵌套酒吧和所有酒吧嵌套酒吧。那可能嗎?
我希望我試圖保持例子抽象有道理:)