1

我在生产模式下部署应用程序,但是当我尝试完成该过程时,显示了对sqlite适配器的这种需求,请有人知道如何制止这个问题?如何停止安装sqlite3适配器:服务器上的`gem install activerecord-sqlite3-adapter`

我一直在使用RAILS_ENV =生产,但在这种情况下没有奏效。

current$ rails generate admin_interface:setup RAILS_ENV=production 
DEPRECATION WARNING: Support for Rails < 4.1.0 will be dropped. (called from warn at /home/ubuntu/.rbenv/versions/2.2.2/lib/ruby/2.2.0/forwardable.rb:183) 
/home/ubuntu/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/rubygems_integration.rb:322:in `block in replace_gem': Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.) (LoadError) 
    from /home/ubuntu/vitrineonline/releases/10/vendor/bundle/ruby/2.2.0/gems/activerecord-3.2.22/lib/active_record/connection_adapters/sqlite3_adapter.rb:3:in `<top (required)>' 
    from /home/ubuntu/vitrineonline/releases/10/vendor/bundle/ruby/2.2.0/gems/backports-3.6.8/lib/backports/std_lib.rb:9:in `require' 
    from /home/ubuntu/vitrineonline/releases/10/vendor/bundle/ruby/2.2.0/gems/backports-3.6.8/lib/backports/std_lib.rb:9:in `require_with_backports' 
    from /home/ubuntu/vitrineonline/releases/10/vendor/bundle/ruby/2.2.0/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `block in require' 
    from /home/ubuntu/vitrineonline/releases/10/vendor/bundle/ruby/2.2.0/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:236:in `load_dependency' 
    from /home/ubuntu/vitrineonline/releases/10/vendor/bundle/ruby/2.2.0/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require' 
    from /home/ubuntu/vitrineonline/releases/10/vendor/bundle/ruby/2.2.0/gems/activerecord-3.2.22/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection' 

回答

0

第一个问题,我看到的是,你应该把RAILS_ENV声明在你的命令的开始,因为这个设置指令的生活该变量。

RAILS_ENV=production bundle exec rails generate admin_interface:setup 

这可能是完全根本原因。 (还要注意使用bundle exec可以肯定的是,在Gemfile中指定的宝石被正确加载)

如果你想将其设置为外壳,运行:

export RAILS_ENV=production 

所以你不必为每个命令手动设置它。

第二种可能性是数据库适配器没有正确配置。如果这是一个Ruby on Rails应用程序,则数据库适配器在config/database.yml中定义。如果没有指定,它可能默认为sqlite3。确保你有一个正确设置的database.yml文件。

production: 
    adapter: postgresql 
    database: rails4_stack 
    username: myusername 
    password: mypassword 
    pool: 5 
    timeout: 5000 
    encoding: utf8 
    reconnect: false 
+0

非常感谢。 – jjplack

相关问题