I have this code:
module Api::V1
class ConsultanciesApiController < Api::V1::ApiController
before_action :set_consultancy, only: [:show]
def show
render json: @consultancy.to_json(include: [:profiles])
end
private
def set_consultancy
@consultancy = Consultancy.find(params[:consultancy_id])
end
end
end
i have to include :sender
, because in table consultancies i have a sender_id and i have to print the full_name not the id
how can i do?
CodePudding user response:
You can include multiple associations:
render json: @consultancy.to_json(include: [:profiles, :sender])