jeudi 12 novembre 2015

How to include two nested associated siblings in json - Rails

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

Aucun commentaire:

Enregistrer un commentaire