开发者

rails 3 render json and include profile from array

All Users have one profile.

Currently have:

render :json => @user, :include => 开发者_开发知识库[:friends, :requested_friends]

Would like to include the profile for friends and requested friends.

I know for a single include I can user this

render :json => @user, :include => {:requested_friends => {:include => :profile}}

But need something like:

render :json => @user, :include => {[:friends, :requested_friends] => {:include => :profile}}


How about:

render :json    => @user,
       :include => {
           :requested_friends => { :include => :profile },
           :friends           => { :include => :profile }
       }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜