Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails can't find database.yml

I just removed my database.yml because I'm trying to use Mongoid, and now I'm getting the following:

$ rails server           
=> Booting WEBrick
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application/configuration.rb:88:in `read': No such file or directory - /home/chris-kun/code/thirsty/config/database.yml (Errno::ENOENT)
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application/configuration.rb:88:in `database_configuration'
        from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/railtie.rb:58:in `block (2 levels) in <class:Railtie>'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
        from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/railtie.rb:57:in `block in <class:Railtie>'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `instance_exec'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `run'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:50:in `block in run_initializers'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `each'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `run_initializers'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:134:in `initialize!'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
        from /home/chris-kun/code/thirsty/config/environment.rb:5:in `<top (required)>'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `block in require'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `block in load_dependency'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
        from /home/chris-kun/code/thirsty/config.ru:3:in `block in <main>'
        from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
        from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
        from /home/chris-kun/code/thirsty/config.ru:1:in `new'
        from /home/chris-kun/code/thirsty/config.ru:1:in `<main>'
        from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:35:in `eval'
        from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:35:in `parse_file'
        from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/server.rb:162:in `app'
        from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/server.rb:253:in `wrapped_app'
  1 #!/usr/bin/env ruby
        from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/server.rb:204:in `start'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands/server.rb:65:in `start'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:30:in `block in <top (required)>'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

Any ideas?

like image 868
Chris Bolton Avatar asked Jun 21 '11 03:06

Chris Bolton


1 Answers

For those of you who want to use db related functions ex) rake db:seed with mongoid, also add the mongoid railtie:

https://github.com/mongodb/mongoid/tree/master/lib/mongoid/railties

require "rails"

# Import gems in Gemfile
Bundler.require(*Rails.groups)

# important that this is imported after gems in Gemfile are imported
%w(
  mongoid
  action_controller
  action_mailer
  active_resource
  rails/test_unit
).each do |framework|
begin
  require "#{framework}/railtie"
    rescue LoadError
  end
end
like image 75
jrhee17 Avatar answered Oct 29 '22 02:10

jrhee17