If you are using Rails API and Ember JS and enable coalescing in Ember Data (example), Ember Data will coalesce your queries into one that will automatically hit your index controller with an ids parameter of what it wants.
How do you update the index controller? Is there a ActiveRecord function for retrieving all or some records based on a parameter being included?
def index
ids = params[:ids]
if ids.present?
@advertisers = Advertiser.where(id: ids)
else
@advertisers = Advertiser.all
end
render json: @advertisers
end
Aucun commentaire:
Enregistrer un commentaire