Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Extends ignores eager loaded data #380

Closed
simonc opened this Issue · 1 comment

2 participants

@simonc

Say I have the following models

class Region < ActiveRecord::Base
  has_many :departments
end

class Department < ActiveRecord::Base
  belongs_to :region
end

In my controller I use includes because I need the department ids in my template.

class RegionsController < ApplicationController
  def index
    @regions = Regions.includes(:departments).all
  end
end

When I don't use extends in my template it works fine with only 2 queries.

# app/views/regions/index.json.rabl
collection @regions
attributes :id, :name, :department_ids

But, when I use extends the eager loaded data are ignored and N+1 queries come around.

# app/views/regions/index.json.rabl
collection @regions
extends 'regions/show'

# app/views/regions/show.json.rabl
object @region
attributes :id, :name, :department_ids
@nesquena
Owner

I think this has been fixed. If not, please re-open

@nesquena nesquena closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.