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

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 生产环境错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
开始,我是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

database.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

的Gemfile:

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

解决方法

这些是要考虑的事情

> MysqL2在Gemfile中(它是)>在config / database.yml中定义的生产环境(它是)2.2从database.yml中删除任何其他环境,并留下生产:只确保它正确缩进(我认为是)>安装捆绑(确保您已安装宝石)> bundle显示MysqL2看到的版本,并确保它的安装> bundle exec rails s -e production(确保使用bundle exec)>如果这不行,我会看看config / environments / production.rb,确保没有什么罕见的.

原文链接:https://www.f2er.com/ruby/272656.html

猜你在找的Ruby相关文章