Posted by: mikewilliamson on: March 21, 2011
I am just finishing a simple app that doesn’t require a database. When running it on the server I was getting errors saying :
LoadError (no such file to load — sqlite3):
But it was already commented out of my Gemfile. It took some thinking before I realized that ActiveRecord is probably looking for that by default regardless of whether or not I am including it in my Gemfile. So the solution was to remove ActiveRecord. That used to be reasonably obvious in Rails 2.3 but Rails 3 made it a little less so. A standard config.application.rb file starts with the lines:
require File.expand_path(‘../boot’, __FILE__)
require ‘rails/all’
Rails 3 is broken up into a bunch of different parts and that require ‘rails/all’ pulls in, well all of them including ActiveRecord. An equivalent statement would be:
require “active_record/railtie”
require “action_controller/railtie”
require “action_mailer/railtie”
require “active_resource/railtie”
require “rails/test_unit/railtie”
Of course once you have exchanged ‘rails/all’ for that, you can simply comment out ActiveRecord and that’s that. If you are starting a new Rails app you can have Rails do that for you by using the flags -O or –skip-activerecord.
Now that AR is gone, my app starts without looking for a database and all is goodness and light.
July 29, 2011 at 9:24 pm
In rails 3.1 you also need sprockets:
require “sprockets/railtie”