Ruby on rails 如何在json-Rails中包含两个嵌套的关联同级

Ruby on rails 如何在json-Rails中包含两个嵌套的关联同级,ruby-on-rails,json,ruby-on-rails-3,api,ruby-on-rails-4,Ruby On Rails,Json,Ruby On Rails 3,Api,Ruby On Rails 4,我有这个结构 user -> profile -> address (table) -> workplace (table) 我有一段代码,它不能像预期的那样工作,它不能输出地址嵌套关联 def index @users = User.all render json: @users.as_json(include: [:profile => {

我有这个结构

user
   -> profile
       -> address (table)
       -> workplace (table)
我有一段代码,它不能像预期的那样工作,它不能输出地址嵌套关联

def index
    @users = User.all
    render json: @users.as_json(include: 
                                  [:profile => { 
                                    :include => :address,:include =>:workplace 
                                    }
                                  ]
                                )

  end

我设法使它工作在这里是答案,供将来参考

def index
    @users = User.all
    render json: @users.as_json(include:
                                  [:profile => {
                                    :include => [:address,:workplace]
                                    }
                                  ]
                                )

  end

确保下次在问题上指定关联。说
structure
是含糊不清的。title说嵌套关联,不过还是谢谢你的提示!