0
如何控制.json請求中返回的對象?我得到了相關聯的對象,而不是主要對象 - 產品,而不是公司,在我下面的例子:Respond_with JSON @object發送關聯對象,而不是@object?
class Company
has_many :products
include Enumerable
class Product
belongs_to :company
controller Company
respond_to :html, :json
def show
@company = Company.find(1)
respond_with @company
end
**respond_with @company ==> json of products, not company!**
respond_with @company.id ==> json of :id
你可以發佈你的控制器的相關部分? – Robin 2011-12-14 16:16:12