2

I have a rails 2 app that I'm upgrading to use bundler. Unfortunately, this app does not use active_record (but uses every other component of rails heavily).

Previously, to have the app ignore active_record I had the following in my environment.rb file:

config.frameworks -= [ :active_record ]

However, it seems that bundler is forcing active_record to load which obviously throws errors since there isn't a database specified.

I'm using rails 2.3.16 (actually attempting to upgrade to it as part of this process).

I've searched around a bit, and the closest I have found was this open ticket:

https://github.com/wycats/bundler/issues/143

Is my only option to explicitly modify the Gemfile.lock and remove all references to active_record?

tereško
  • 58,060
  • 25
  • 98
  • 150
gmoniey
  • 7,975
  • 4
  • 27
  • 30

1 Answers1

0
  • Check that your config/application.rb doesn't have require 'rails/all' or require "active_record/railtie". Instead, for a standard Rails setup without ActiveRecord, it should have only the following requires:

    require File.expand_path('../boot', __FILE__)
    
    require "action_controller/railtie"
    require "action_mailer/railtie"
    require "active_resource/railtie"
    require "rails/test_unit/railtie"
    require "sprockets/railtie"
    
    # Auto-require default libraries and those for the current Rails environment. 
    Bundler.require :default, Rails.env
    
  • If, in config/application.rb, you are using the config.generators section, make sure it doesn't have the line g.orm :active_record. You can set this explicitly to nil, if you want, but this should be the default when g.orm is completely omitted.

  • Optional, but in your Gemfile, remove the gem line that loads the module for your database. This could be the line gem "mysql" for example.

(from here)

Community
  • 1
  • 1
Chris Cashwell
  • 22,308
  • 13
  • 63
  • 94
  • I'm on Rails 2.3.16, so there isn't a application.rb file I can modify. I tried removing the gem 'mysql' line as well, but that didn't help. – gmoniey Feb 06 '13 at 15:28
  • Spoke too soon...forgot to run 'bundle update' when I removed mysql. That seems to have fixed it...thanks! I'll post back if I run into additional trouble. – gmoniey Feb 06 '13 at 18:18