nesquena / rabl

General ruby templating with json, bson, xml, plist and msgpack support
http://blog.codepath.com/2011/06/27/building-a-platform-api-on-rails/
MIT License
3.64k stars 334 forks source link

N+1 issues #736

Open cw6365 opened 4 years ago

cw6365 commented 4 years ago

I've got the following call in Rails 4

@obj = A.includes(B: { C: D}).find_by_uuid(params[:id])

Which works fine when viewing the SQL. The problem is the following RABL template creates multiple D database queries again. I'm using 0.14.0. This is the structure of my simplified Rabl.

show.rabl

object @obj
extends "documents/base"

base.rabl

child :B => :asb do |ab|
    object ab
    extends "shared/asb"
end

asb.rabl

child(:C => :csb) do
    attributes :id 
    child(:D => :dsb) do
         attributes :x, :y <<----------- multiple database calls
    end
  end
rbarrera87 commented 1 year ago

Did you find the solution for this @cw6365 ? I am facing the same issue I found this https://github.com/nesquena/rabl/issues/142#issuecomment-2964059 but that is not working either.