ActiveRecord :: ConnectionNotEstablished Ruby on Rails

时间:2016-06-11 23:34:38

标签: ruby-on-rails activerecord

我在Ruby on Rails上使用mysql2,遵循Kevin Skoglund的Ruby on Rails 4 Essential Training,并且我在前面的章节中告诉我通过键入'来访问项目。 rails server'并打开本地主机:3000'在我的浏览器上。

问题是这样的: Connection not Established

所以我无法访问我的项目,也无法继续学习。

另外,我注意到我和教程的终端之间有所不同。在我的终端中,在启动WEBrick之前,它显示了这个: /home/jmmaglinao16/.rvm/gems/ruby-2.3.0/gems/activesupport-4.0.0/lib/active_support/values/time_zone.rb:282:警告:循环参数参考 - 现在

我不确定它是否与问题有任何联系,但这是我迄今为止所拥有的。请帮帮我们。谢谢。

的Gemfile:

source 'rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

# Use mysql as the database for Active Record
gem 'mysql2'

# Use SCSS for stylesheets
#gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
#gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
#gem 'coffee-rails', '~> 4.0.0'

# See  for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
#gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: 
#gem 'turbolinks'

# Build JSON APIs with ease. Read more: 
#gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

database.yml中:

# MySQL.  Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
#   gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
#   gem 'mysql2'
#
# And be sure to use new-style password hashing:
#   
development:
  adapter: mysql2
  encoding: utf8
  database: #simple_cms_development
  pool: 5
  username: root
  password: mypass
  socket: /var/run/mysqld/mysqld.sock

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  encoding: utf8
  database: simple_cms_test
  pool: 5
  username: root
  password: mypass
  socket: /var/run/mysqld/mysqld.sock

production:
  adapter: mysql2
  encoding: utf8
  database: simple_cms_production
  pool: 5
  username: root
  password: mypass
  socket: /var/run/mysqld/mysqld.sock

1 个答案:

答案 0 :(得分:0)

尝试使用'#'在这行的开头像这样:
#database:simple_cms_development