Short Version: How to determine which file or gem is requiring a certain file
A bit longer ..
I have a Rails 3.0.3 / mongoid application, so I am not using ActiveRecord. The top of my application.rb file looks like so:
require File.expand_path('../boot', __FILE__)
#require 'rails/all'
require "action_controller/railtie"
require "action_mailer/railtie"
But after rails loads, if I go into the console and type:
defined?(ActiveRecord::Base)
#=> "constant"
I expected it to be nil.
So one of my gems must be loading ActiveRecord.
How do I determine which gem or file is requiring ActiveRecord?
Ok, I figured out a way to do it, but not sure its the best:
Since I am using bundler, I simply added a break point after bundler requires the file, and then check afterwards if the file was loaded.
I added the breakpoint in
Bundler::Runtime#requireat theKernel.requireline.Chime in if there is a more elegant way.