0
我有下面的類層次結構:嵌套JSON ActiveRecord的
class User < ActiveRecord::Base
has_many :projects
end
class Project < ActiveRecord::Base
belongs_to :user
has_many :project_personas
has_many :personas, through: :project_personas
end
class ProjectPersona < ActiveRecord::Base
belongs_to :project
belongs_to :persona
end
class Persona < ActiveRecord::Base
end
,我試圖讓用戶像一個JSON:
render json: @user.to_json(
include: {
projects: {
include: :personas
}
})
什麼不實際工作。什麼是工作是:
render json: @user.to_json(
include: {
projects: {
include: {
project_personas: {
include: :persona
}
}
}
})
但我不想有這個project_personas
級別。 我該怎麼辦?
是的,而是'User.where(:GUID => '12 -2-12' )'和得到的結果'用戶{項目:{角色:{persona1,...}}}' – squixy
哪些呢在查詢該對象時在控制檯或瀏覽器中呈現的內容? – Dap