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 load -- sqlite3
, even though no code in the application requires sqlite, except I left database.yml with its default setting for sqlite3, since removing the content raised other errors. Any idea how I could use rails without any database and avoid said errors? thanks.
(also, I'm familiar with Sinatra - just prefer rails for this project).
With rails 6 multiple DB support, you can have more than one database with a replica (read-only copy) of each database. Now, consider your rails application with a single primary database, and now after upgrading to Rails 6, you need to add a new database for some of the new tables. The current version of your database.yml looks like:
Rails 6.0 ships with all the rails tasks you need to use multiple databases in Rails. You can run bin/rails -T to see all the commands you're able to run. You should see the following:
As a first-time multiple database user, my basic understanding of how Rails + Active Record manages the interactions with a single database went something like this: Rails gives us a database.yml file where we write some mysterious configurations. Active Record does the things (technical term) and magically connects the app to a database.
You can swap the role and the shard with the connected_to API. In Rails 6.1 it's possible to switch connections for one database instead of all databases globally. To use this feature you must first set config.active_record.legacy_connection_handling to false in your application configuration.
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 -=
!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With