Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binding_of_caller and scope instance variables #134

Closed
elDub opened this issue Feb 23, 2013 · 4 comments
Closed

binding_of_caller and scope instance variables #134

elDub opened this issue Feb 23, 2013 · 4 comments

Comments

@elDub
Copy link

elDub commented Feb 23, 2013

When the better_errors page is displayed with the binding_of_caller gem enabled, any ActiveRecord scopes are inspected/expanded, which can result in entire database tables being loaded and inspected. Is it possible, or even acceptable in this situation, to perhaps not inspect the scope but rather '.to_sql' it? Maybe make that an option? Or perhaps this is more of an issue for the binding_of_caller gem?

For example, if the companies table has thousands of active records, the following will trigger a very large amount of output:

class CompaniesController < ApplicationController
  before_filter :set_resource_scope

  def index
    @resource_scope = @resource_scope.order(Company.arel_table[:name].asc)
    raise Exception
  end

  private

  def set_resource_scope
    @resource_scope = Company.active
  end
end
@cknoxrun
Copy link

+1, I'm having this issue as well.

@findchris
Copy link

Any idea why this is happening?

@haileys
Copy link
Collaborator

haileys commented May 1, 2013

This happens because the inspect method on ActiveRecord::Relation actually performs the query and inspects the result data. I believe Rails 4 changes this behaviour so inspect doesn't dump such a massive amount of data.

@haileys
Copy link
Collaborator

haileys commented Aug 2, 2013

This is fixed in Rails 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants