如何使用我的rails应用程序解决此sqlite问题?

时间:2014-12-12 04:10:14

标签: ruby-on-rails ruby-on-rails-4 sqlite

我刚将我的应用程序部署到heroku上。但是,现在当我尝试切换回开发并在命令提示符下运行rails c时,我收到以下错误:

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require': cannot load such file -- sqlite3/database
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `block in require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.10-x86-mingw32/lib/sqlite3.rb:9:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler/runtime.rb:76:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler/runtime.rb:72:in `each'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler/runtime.rb:72:in `block in require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler/runtime.rb:61:in `each'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler/runtime.rb:61:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler.rb:133:in `require'
        from D:/Railstutorials/Taxibol/Platform/iteration2/taxibol_operator/config/application.rb:9:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:146:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:146:in `require_application_and_environment!'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:68:in `console'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

以下是我的database.yml文件:

default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

test:
  <<: *default
  database: db/test.sqlite3

production:
  adapter: postgresql  
  host: ec2-23-23-210-37.compute-1.amazonaws.com
  port: 5432
  database: d9qgibt6qabecr  
  username: ygaayqvpdrfjwa
  password: 'my_password'

当我想在开发模式下启动服务器时,我遇到了同样的问题。我哪里可能出错?

2 个答案:

答案 0 :(得分:0)

运行rake db:create并且工作正常。虽然我不知道为什么。如果有人可以解释,那会很棒......

答案 1 :(得分:0)

我建议您在本地安装Postgres,以便您的开发和生产环境相同。

有时在进行故障排除时,在本地运行您的生产环境会很有帮助,因为可能还有一些其他设置,您可能不会注意到这些设置在生产与开发方面有所不同。在本地运行生产是测试它的快速方法,因此您需要在本地安装Postgres,因为这是您在database.yml中设置的内容。

这是从终端本地运行生产服务器或生产控制台的方法: RAILS_ENV =生产轨道服务器 要么 RAILS_ENV =生产rails控制台

仅供参考,Mac用户安装Postgres的好方法是使用http://postgresapp.com/,因为使用CMD + SPACE_BAR(使用Spotlight进行系统搜索)并输入&#34; postgres&#很容易34。