# Does Rails 2.0 \*require\* a db? Sure seems that way

**URL:** <https://www.ruby-forum.com/t/does-rails-2-0-require-a-db-sure-seems-that-way/121352>\
**Category:** Rails\
**Created:** [November 27, 2007, 5:23am UTC](https://www.ruby-forum.com/t/does-rails-2-0-require-a-db-sure-seems-that-way/121352 "2007-11-27T05:23:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrwhite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rrwhite](https://www.ruby-forum.com/u/rrwhite)\
**Post date:** [November 27, 2007, 5:23am UTC](https://www.ruby-forum.com/t/does-rails-2-0-require-a-db-sure-seems-that-way/121352/1 "2007-11-27T05:23:24Z")

</div>

I do a number of protoype apps in Rails and up until 2.0 I haven’t had  
any issues running them without a DB.

I’m running a naked Rails 2.0 app with only a few views, no ActiveRecord  
models and using the default session store (zee Cookied one):

* * *

Processing EventsController#index (for 127.0.0.1 at 2007-11-26 20:07:29)  
[GET]  
Session ID:  
BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%0ASGFzaHsABjoKQHVzZWR7AA%3D%3D–b922ebe60d92900bcef0795360cd  
Parameters: {“action”=\>“index”, “controller”=\>“events”}

Mysql::Error (#42000Incorrect database name  
‘prototype.com\_development’):  
/vendor/rails/activerecord/lib/active\_record/vendor/mysql.rb:523:in  
`read' /vendor/rails/activerecord/lib/active_record/vendor/mysql.rb:153:in`real\_connect’  
/vendor/rails/activerecord/lib/active\_record/connection\_adapters/mysql\_adapter.rb:471:in  
`connect' /vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:165:in`initialize’  
/vendor/rails/activerecord/lib/active\_record/connection\_adapters/mysql\_adapter.rb:88:in  
`new' /vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:88:in`mysql\_connection’  
/vendor/rails/activerecord/lib/active\_record/connection\_adapters/abstract/connection\_specification.rb:291:in  
`send' /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in`connection=’  
/vendor/rails/activerecord/lib/active\_record/connection\_adapters/abstract/connection\_specification.rb:259:in  
`retrieve_connection' /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in`connection’  
/vendor/rails/activerecord/lib/active\_record/query\_cache.rb:8:in  
`cache' /vendor/rails/actionpack/lib/action_controller/caching.rb:668:in`perform\_action’  
/vendor/rails/actionpack/lib/action\_controller/base.rb:513:in `send' /vendor/rails/actionpack/lib/action_controller/base.rb:513:in`process\_without\_filters’  
/vendor/rails/actionpack/lib/action\_controller/filters.rb:685:in  
`process_without_session_management_support' /vendor/rails/actionpack/lib/action_controller/session_management.rb:123:in`process’  
/vendor/rails/actionpack/lib/action\_controller/base.rb:377:in  
`process' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:171:in`handle\_request’  
/vendor/rails/actionpack/lib/action\_controller/dispatcher.rb:115:in  
`dispatch' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:126:in`dispatch\_cgi’  
/vendor/rails/actionpack/lib/action\_controller/dispatcher.rb:9:in  
`dispatch' c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:78:in`process’  
c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in  
`synchronize' c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in`process’  
c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:618:in  
`process_client' c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in`each’  
c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in  
`process_client' c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`run’  
c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`initialize' c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`new’  
c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`run' c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in`initialize’  
c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in  
`new' c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in`run’  
c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:271:in  
`run' c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in`each’  
c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in  
`run' c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:127:in`run’  
c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/command.rb:211:in  
`run' c:/dev/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:243 /vendor/rails/activesupport/lib/active_support/dependencies.rb:489:in`load’  
/vendor/rails/activesupport/lib/active\_support/dependencies.rb:489:in  
`load' /vendor/rails/activesupport/lib/active_support/dependencies.rb:342:in`new\_constants\_in’  
/vendor/rails/activesupport/lib/active\_support/dependencies.rb:489:in  
`load' /vendor/rails/railties/lib/commands/servers/mongrel.rb:64 c:/dev/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
c:/dev/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' /vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in`require’  
/vendor/rails/activesupport/lib/active\_support/dependencies.rb:342:in  
`new_constants_in' /vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in`require’  
/vendor/rails/railties/lib/commands/server.rb:39  
c:/dev/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' c:/dev/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
script/server:3

* * *

WTF Mates? Here’s the oh so exciting environment.rb:

– environment.rb –

# Specifies gem version of Rails to use when vendor/rails is not present

#RAILS\_GEM\_VERSION = ‘1.2.5’ unless defined? RAILS\_GEM\_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration

require File.join(File.dirname( **FILE** ), ‘boot’)

Rails::Initializer.run do |config|  
config.action\_controller.session = { :session\_key =\> “\_prototype”,  
:secret =\> “not so secretive” }  
end

* * *

Anyone have any ideas on why it needs a db? Thanks

Rich

---

<div class="post-metadata">

**Author:** ![rrwhite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rrwhite](https://www.ruby-forum.com/u/rrwhite)\
**Post date:** [November 27, 2007, 5:41am UTC](https://www.ruby-forum.com/t/does-rails-2-0-require-a-db-sure-seems-that-way/121352/2 "2007-11-27T05:41:49Z")

</div>

Nope. Just do this in your environment.rb:

config.frameworks -=  
[:active\_record, :action\_web\_service, :action\_mailer]

All will then be well (or, at least it works for me 🙂

---

<div class="post-metadata">

**Author:** ![rrwhite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rrwhite](https://www.ruby-forum.com/u/rrwhite)\
**Post date:** [November 27, 2007, 6:00am UTC](https://www.ruby-forum.com/t/does-rails-2-0-require-a-db-sure-seems-that-way/121352/3 "2007-11-27T06:00:03Z")

</div>

Steve R. wrote:

> Nope. Just do this in your environment.rb:
> 
> config.frameworks -=  
> [:active\_record, :action\_web\_service, :action\_mailer]
> 
> All will then be well (or, at least it works for me 🙂

That works and seems like a good practice that I’ll continue. Still  
confused in the silent change as this wasn’t required pre-2.0 if you  
simply never used those frameworks. Moving on though.

Thanks for the help, Steve.

---

<div class="post-metadata">

**Author:** ![rrwhite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rrwhite](https://www.ruby-forum.com/u/rrwhite)\
**Post date:** [November 27, 2007, 12:20pm UTC](https://www.ruby-forum.com/t/does-rails-2-0-require-a-db-sure-seems-that-way/121352/4 "2007-11-27T12:20:16Z")

</div>

On 27 Nov 2007, at 05:00, Richard W. wrote:

> Steve R. wrote:
> 
> > Nope. Just do this in your environment.rb:
> > 
> > config.frameworks -=  
> > [:active\_record, :action\_web\_service, :action\_mailer]
> > 
> > All will then be well (or, at least it works for me 🙂

I’ve got a small app which doesn’t use active\_record

I did have to comment out #require ‘test\_help’ in my test\_helper.rb  
(since that requires fixtures, which in turn needs ActiveRecord) (and  
then copied into my test\_helper.rb the bits from test\_help which were  
relevant.

I also had to edit environment.rb to add

module Rails  
class Initializer  
def load\_observers  
if configuration.frameworks.include?(:active\_record)  
ActiveRecord::Base.instantiate\_observers  
end  
end  
end  
end

Fred
