I'm new to rails and stuck between eager-loading from last 2 days. I have two models Car
and Images
with Car has_many :images
association. and I have made an api which returns json array of cars with their images. I want single image instead all images from association. I'm using like:
Car.where(:company=>"BMW").as_json(:include=> {:images})
This will return all the cars with their all images. I want all cars with their single image instead of all images array.
Aucun commentaire:
Enregistrer un commentaire