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

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

当我使用Heroku的打开我的web应用程序工作正常,但当我用钢轨S(本地)我遇到了这个错误:

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

这是为什么?

这是我的database.yml

#PostgreSQL的。版本8.2及以上的支持。 # #安装PG驱动程序: #创业板安装PG #在与自制OS X: #创业板安装PG - --with-PG-配置=在/ usr / local / bin目录/ pg_config #在与MacPorts的OS X: #创业板安装PG - --with-PG-配置= /选择/ local / lib目录/ postgresql84 /斌/ pg_config #在Windows上: #创业板安装PG #选择在Win32版本。 #安装PostgreSQL,并把它的/ bin目录的路径。 # #配置使用的Gemfile #宝石PG # 默认:放大器;默认   适配器:PostgreSQL的   编码:UNI code   #有关连接池的详细信息,请参阅导轨配置指南   #guides.rubyonrails/configuring.html#database-pooling   池:5

这是我的Gemfile:

来源rubygems 创业板PG 创业板自举 - 萨斯,GT〜&; 3.1.1 #捆绑边缘轨道,而不是:创业板轨,github上:导轨/导轨 创业板导轨,4.0.3 #使用SCSS的样式表 创业板上海社会科学院护栏,GT〜&; 4.0.0 #使用Uglifier作为COM pressor对JavaScript资产 创业板uglifier','> = 1.3.0' #使用的CoffeeScript的.js.coffee资产和意见 创业板咖啡轨,GT〜&; 4.0.0 #见github/sstephenson/execjs#readme更多的支持运行时 #创业板therubyracer',平台:红宝石 #使用jQuery的JavaScript库 创业板的jQuery护栏 #Turbolinks使得Web应用程序以下链接速度更快。了解更多:github/rails/turbolinks 创业板turbolinks #构建JSON API的轻松。了解更多:github/rails/jbuilder 创业板的JBuilder,GT〜&; 1.2 组:DOC做   #捆绑EXEC耙DOC:导轨产生下DOC / API的API。   创业板SDOC,要求:假的 结束 组:生产做   创业板rails_12factor,0.0.2 结束 #使用加载ActiveModel has_​​secure_password #创业板bcrypt-红宝石','〜> 3.1.2 #使用麒麟作为应用服务器 #宝石'麒麟' #使用Capistrano的部署 #创业板Capistrano的,群:发展 #使用调试器 #宝石调试,群:[:开发:测试]

解决方案

有关您的应用程序在本地工作,你需要:

  • 你的机器上安装PostgreSQL
  • 创建一个数据库为您的发展需要(我们称之为 my_app_development )
  • 更​​改的database.yml 来:

    默认:放大器;默认   适配器:PostgreSQL的   编码:UNI code   #有关连接池的详细信息,请参阅导轨配置指南   #guides.rubyonrails/configuring.html#database-pooling   池:5 发展:   <<:*默认   数据库:my_app_development

  • 运行耙分贝:迁移

  • 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

    Why is this?

    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

    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:

  • 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

  • run rake db:migrate

  • 更多推荐

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

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

    发布评论

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

    >www.elefans.com

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