当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby on rails - tell bundler to ignore certain dependencies?

问题描述:

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?

网友答案:
  • 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)

分享给朋友:
您可能感兴趣的文章:
随机阅读: