Rails 3 - how do I avoid database altogether?

前端 未结 2 1515
难免孤独
难免孤独 2020-12-02 06:37

I\'m trying to use rails 3 without any db backend, but it still insists on requiring \'sqlite3\' gem when I try to access a page, and throws an error no such file to l

2条回答
  •  有刺的猬
    2020-12-02 07:00

    Rails 3:

    In application.rb, remove the require 'rails/all' line and instead add these lines:

    require "action_controller/railtie"
    require "action_mailer/railtie"
    require "active_resource/railtie"
    require "rails/test_unit/railtie"
    require "sprockets/railtie"
    

    Also see Remove ActiveRecord in Rails 3 and look into the Active Model railscast

    Rails 3.2.x:

    You'll also need to remove/comment out this line in application.rb

    config.active_record.whitelist_attributes = true
    

    And remove/comment these two lines from development.rb

    config.active_record.mass_assignment_sanitizer = :strict
    config.active_record.auto_explain_threshold_in_seconds = 0.5
    

    Rails 2.x:

    In config/environment.rb add (or uncomment) the line

    config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
    

    This will cause Rails not to use those frameworks. (Note the nearly-invisible -= !)

提交回复
热议问题