I need some help I have a controller with an action that queries two models. Now I need to send both of them as json in order to be used on my angular views.
In the example bellow how should I send the "complex" and its "fields" in one json response?
Ex.
def complexes_and_fields
complex = Complex.find(params[:id])
search_params = {complex_id: complex._id}
fields = Field.where(search_params)
if !complex.nil?
render json: ???.to_json, status: :ok
else
render json: { error_description: 'no complex found' },status: :bad_request
end
Aucun commentaire:
Enregistrer un commentaire