Rails 3 - how do I avoid a database at all?

I try to use rails 3 without the db backend, but it still insists on creating a "sqlite3" gem when I try to access the page, and throws no such file to load -- sqlite3 , although sqlite is not required in any application , except that I left the .yml database with the default setting for sqlite3, as deleting the content caused other errors. Any idea how I can use rails without any database and avoid the indicated errors? thank.

(I am also familiar with Sinatra - I just prefer rails for this project).

+45
ruby-on-rails-3
Oct 17 '10 at 17:12
source share
2 answers

Rails 3:

In application.rb delete the line require 'rails/all' and add the following lines instead:

 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 see Active Model railscast

Rails 3.2.x:

You also need to delete / 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 to not use these frameworks. (Note the almost invisible -= !)

+98
Oct 17 2018-10-17
source share

Also, in Rails 3, remove any active_record links in

configurations / environment / development.rb

config / environment / test.rb and

config / environment / production.rb e.g.

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

and deletion requires "rails / all" and the addition of query lines in comment 21 (see above).

if you are not using a database (this works with Rails 3.1.1)

+10
Jan 31 2018-12-12T00:
source share



All Articles