Bacancy Technology
Bacancy Technology represents the connected world, offering innovative and customer-centric information technology experiences, enabling Enterprises, Associates and the Society to Rise™.
12+
Countries where we have happy customers
1050+
Agile enabled employees
06
World wide offices
12+
Years of Experience
05
Agile Coaches
14
Certified Scrum Masters
1000+
Clients projects
1458
Happy customers
Artificial Intelligence
Machine Learning
Salesforce
Microsoft
SAP
October 28, 2024
To modify how Rails serializes the Apprenticeship object into JSON, you can use the as_json method to include the associated records (Jedi and Padawan) as nested objects.
class ApprenticeshipsController < ApplicationController def index # Load all apprenticeships with their associated Jedi and Padawan records @apprenticeships = Apprenticeship.includes(:jedi, :padawan).all # Render JSON with nested Jedi and Padawan information render json: @apprenticeships.as_json( include: { jedi: { only: [:id, :name] }, padawan: { only: [:id, :name] } } ) end end