gpt4 book ai didi

ruby-on-rails - RSpec: `initialize':致命:用户密码验证失败

转载 作者:太空宇宙 更新时间:2023-11-03 16:45:37 25 4
gpt4 key购买 nike

我的 Rails 应用程序运行完美,但是当我尝试应用一些模型测试时 RSpec 抛出错误:

/home/luka/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `initialize': FATAL:  password authentication failed for user "luka" (PG::ConnectionBad)
FATAL: password authentication failed for user "luka"

这是我的 database.yml 文件:

    default: &default
adapter: postgresql
encoding: unicode
host: localhost
username: luka
password: 4129235
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5

test:
<<: *default
database: postdb_test

这是我运行的测试:

require 'spec_helper'
require 'rails_helper'

describe Student do
it "creates valid entry"
end

gem 文件:

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use postgresql as the database for Active Record
gem 'pg'
...
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'devise'
gem 'rails_12factor', group: :production
gem 'cancancan'
gem 'rspec-rails'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

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

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

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end

我安装了一个 pg,使用正确的密码创建了用户,并使用正确的所有者创建了“postdb”。我已经在配置中从 peer 更改为 md5。什么都没发生。

UPD:看起来问题出在“postgres”用户中。命令“createdb”和 CREATE DATABASE 什么也没做,CREATE USER 和 ALTER USER 也是如此

最佳答案

不知道它是什么,但是通过重新安装 postgre 治愈了。

关于ruby-on-rails - RSpec: `initialize':致命:用户密码验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33344548/

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