Topic: rake db:create failing -

All of a sudden, rake db:create isn't working for my project. Any help to get me going in the right direction is greatly appreciated.

I get this error:

rake aborted!
#42000Unknown database 'ynp_development'

Here's the full trace if it helps:

** Invoke db:create (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
#42000Unknown database 'ynp_development'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/vendor/mysql.rb:523:in `read'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/vendor/mysql.rb:153:in `real_connect'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:471:in `connect'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:165:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:88:in `new'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:88:in `mysql_connection'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in `connection='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:259:in `retrieve_connection'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1063:in `table_exists?'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1153:in `inspect'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/symbol.rb:11:in `__send__'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/symbol.rb:11:in `to_proc'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:426:in `collect'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:426:in `log_call'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:222:in `load_missing_constant'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:469:in `const_missing'
/Users/damoncali/dev/ynp/app/models/user.rb:3
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:203:in `load_without_new_constant_marking'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:203:in `load_file'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:202:in `load_file'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:94:in `require_or_load'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:248:in `load_missing_constant'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in `const_missing'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/inflector.rb:257:in `constantize'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/string/inflections.rb:148:in `constantize'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/observer.rb:143:in `observed_class'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/observer.rb:169:in `observed_classes'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/observer.rb:152:in `initialize'
/usr/local/lib/ruby/1.8/singleton.rb:95:in `new'
/usr/local/lib/ruby/1.8/singleton.rb:95:in `instance'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/observer.rb:38:in `instantiate_observers'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/observer.rb:36:in `each'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/observer.rb:36:in `instantiate_observers'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:216:in `load_observers'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:108:in `process'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:49:in `send'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:49:in `run'
/Users/damoncali/dev/ynp/config/environment.rb:13
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/tasks/misc.rake:3
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:518:in `invoke_prerequisites'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1183:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1183:in `send'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1183:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:515:in `invoke_prerequisites'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:507:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19

Re: rake db:create failing -

More info:

I have a User model (derived from restful_authentication) that has two of my own modules (from the /lib directory) included. If I remove those includes, it all works again.

Re: rake db:create failing -

It seems rake db:create loads your entire application first (I don't know why it needs to do this). I'm guessing that the modules included by your User model try to access the database at "compile time" (I don't know what the correct ruby terminology for this is) -- for example the module might be trying to define methods based on the rows in a table, and failing because there is no database.