gpt4 book ai didi

ruby-on-rails - 生产环境错误

转载 作者:行者123 更新时间:2023-12-03 22:36:51 26 4
gpt4 key购买 nike

首先,我是 Rails 的新手。我正在制作一个博客应用程序,当尝试在生产环境中运行它时,两种方式:

rails s -e production


RAILS_ENV=production

我犯了同样的错误:

=> Booting WEBrick => Rails 3.2.8 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/loku/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-> resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
...



我的设置:
ruby 1.9.3p286 (2012-10-12 revision 37165) [i686-linux]

Rails 3.2.8

数据库.yml:
development:    
adapter: mysql2
encoding: utf8
reconnect: false
database: blogg_development
pool: 5
timeout: 5000
username: root
password: ***
host: localhost

production:
adapter: mysql2
encoding: utf8
reconnect: false
database: blogg_production
pool: 5
timeout: 5000
username: root
password: ***
host: localhost

gem 文件:
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.8'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platforms => :ruby

gem 'uglifier', '>= 1.0.3'
gem 'haml-rails'
gem 'less-rails'
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap- rails.git'
#gem 'actionpack', '~> 3.1.0'
end

gem 'jquery-rails'
gem 'haml'
gem 'devise'
gem 'cancan'

group :test, :development do
gem 'guard-livereload'
gem 'rb-fsevent'
gem 'pry'
gem 'pry-rails'
end

group :linux do
gem 'libnotify'
end

group :darwin do
gem 'rb-fsevent', require: false
gem 'growl'
end

最佳答案

这些是要考虑的事情

  • Gemfile 中的 mysql2(它是)
  • config/database.yml 中定义的生产环境(它是)
    2.2 从您的 database.yml 中删除任何其他环境并离开生产:仅
  • 确保它正确缩进(我认为是)
  • 捆绑安装(以确保您安装了 gem)
  • bundle show mysql2 以查看版本并确保它已安装
  • bundle exec rails s -e production(确保使用 bundle exec)
  • 如果这不起作用,我会查看 config/environments/production.rb 并确保那里没有任何罕见的东西。
  • 关于ruby-on-rails - 生产环境错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13726492/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com