I have this structure
user
-> profile
-> address (table)
-> workplace (table)
and i have this code that does not work as expected, it does not output the address nested association
def index
@users = User.all
render json: @users.as_json(include:
[:profile => {
:include => :address,:include =>:workplace
}
]
)
end
答案 0 :(得分:0)
我设法让它在这里工作是未来参考的答案
def index
@users = User.all
render json: @users.as_json(include:
[:profile => {
:include => [:address,:workplace]
}
]
)
end