我想在Rails 4中禁用ActiveRecord。在 config/application.rbrequire File.expand_path('../boot', __FILE__)# require 'rails/all' -- commentedrequire "action_controller/railtie"require "action_mailer/railtie"#require "active_resource/railtie" no need#require "rails/test_unit/railtie" no need#require "sprockets/railtie" no need# Require the gems listed in Gemfile, including any gems# you've limited to :test, :development, or :production.Bundler.require(:default, Rails.env)module MyApp class Application < Rails::Application config.app_middleware.delete "ActiveRecord::ConnectionAdapters::ConnectionManagement" endend由于我有一个错误/home/alex/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/railtie/configuration.rb:95:in method_missing: undefined method active_record for #<Rails::Application::Configuration:0x00000002005c38> (NoMethodError)
3 回答
蛊毒传说
TA贡献1895条经验 获得超3个赞
嗨,这是默认的新new_app -O给出的结果
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
在您的config / application.rb中
此外,它没有database.yml,也没有db / migrate / *和schema.rb
慕妹3146593
TA贡献1820条经验 获得超9个赞
由于这仍然是搜索Google以禁用Rails 5的活动记录时的第一击,因此,请在此处添加以下内容:
对于Rails 5
执行@mechanicalfish答案中的所有步骤,但也删除该行
Rails.application.config.active_record.belongs_to_required_by_default = true
从
config/initializers/new_framework_defaults.rb
- 3 回答
- 0 关注
- 599 浏览
添加回答
举报
0/150
提交
取消