ruby Rails Error : ActiveRecord::AdapterNotSpecified
About my application’s environment
| Ruby version | 1.8.6 (i386-mswin32) |
| RubyGems version | 1.3.5 |
| Rack version | 1.0 |
| Rails version | 2.3.5 |
| Active Record version | 2.3.5 |
| Active Resource version | 2.3.5 |
| Action Mailer version | 2.3.5 |
| Active Support version | 2.3.5 |
| Application root | E:/railsdoc/mybook |
| Environment | development |
| Database adapter | mysql |
| Database schema version | 0 |
_______________________________________________________
E:\railsdoc\mybook>ruby script\server
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
e:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in `establish_connection': development database is not configured (ActiveRecord::AdapterNotSpecified)
from e:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
from e:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:438:in `initialize_database'
from e:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:141:in `process'
from e:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send'
from e:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
from E:/railsdoc/mybook/config/environment.rb:9
from e:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from e:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from e:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from e:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
from e:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from e:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:84
from e:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from e:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/server:3
E:\railsdoc\mybook>
____________________________________________
solultion:
Searched a bit over the net, and was sure that there is some problem with my database.yml file.
Couldn't find anything concrete, as I checked to make sure that there is no "tab" space used in the file.
The culprit was the indentation.
In the figure, can you see the difference? In the first case, the arguments after the"development" are properly indented (one space). In the second case, since there is no such indentation, the interpreter attempts to consider "adapter" (and the rests) at the same level as the "development". Try to avoid that.
Hopefully it will save other's efforts.
________________________________________
development:
adapter: mysql
database: mybook
host: localhost
username: root
password: 1234
test:
adapter: mysql
database: mybook
host: localhost
username: root
password: 1234
production:
adapter: mysql
database: mybook
host: localhost
username: root
password: 1234


