ActiveRecord::AdapterNotSpecified 数据库配置未指定适配器

编程入门 行业动态 更新时间:2024-10-25 00:31:52
本文介绍了ActiveRecord::AdapterNotSpecified 数据库配置未指定适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我使用 heroku 时打开我的网络应用程序工作正常但是当我使用 rails s (localhost) 时我遇到了这个错误:

When I use heroku open my web app works fine but when I'm using rails s (localhost) I am running into this error:

ActiveRecord::AdapterNotSpecified database configuration does not specify adapter

这是为什么?

这是我的数据库.yml

This is my database.yml

# PostgreSQL. Versions 8.2 and up are supported. # # Install the pg driver: # gem install pg # On OS X with Homebrew: # gem install pg -- --with-pg-config=/usr/local/bin/pg_config # On OS X with MacPorts: # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config # On Windows: # gem install pg # Choose the win32 build. # Install PostgreSQL and put its /bin directory on your path. # # Configure Using Gemfile # gem 'pg' # default: &default adapter: postgresql encoding: unicode # For details on connection pooling, see rails configuration guide # guides.rubyonrails/configuring.html#database-pooling pool: 5

这是我的 gemfile:

And this is my gemfile:

source 'rubygems' gem 'pg' gem 'bootstrap-sass', '~> 3.1.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.0.3' # 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 github/sstephenson/execjs#readme 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: github/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: github/rails/jbuilder gem 'jbuilder', '~> 1.2' group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false end group :production do gem 'rails_12factor', '0.0.2' end # Use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.1.2' # Use unicorn as the app server # gem 'unicorn' # Use Capistrano for deployment # gem 'capistrano', group: :development # Use debugger # gem 'debugger', group: [:development, :test]

推荐答案

要使您的应用在本地工作,您需要:

For you app to work locally you need to:

  • 在您的机器上安装 Postgresql
  • 创建一个数据库以满足您的开发需求(我们称之为my_app_development)
  • 将您的 database.yml 更改为:

  • Install Postgresql on your machine
  • Create a database for your development needs (let's call it my_app_development)
  • Change your database.yml to: default: &default adapter: postgresql encoding: unicode # For details on connection pooling, see rails configuration guide # guides.rubyonrails/configuring.html#database-pooling pool: 5 development: <<: *default database: my_app_development

  • 运行 rake db:migrate

  • 更多推荐

    ActiveRecord::AdapterNotSpecified 数据库配置未指定适配器

    本文发布于:2023-10-16 10:25:25,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1497301.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:适配器   数据库   ActiveRecord   AdapterNotSpecified

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!