首页 > 解决方案 > 无法加载“pgcrypto”Active Record 适配器

问题描述

我需要在 postgresql 数据库中存储一些机密数据。为了做到这一点,我使用了 pgcrypto gem。我将此 gem 添加到 Gemfile 中,并将 database.yml 中的适配器名称更改为 pgcrypto。并在捆绑安装后执行以下命令。rails generate pgcrypto:install. 但我收到以下错误Could not load the 'pgcrypto' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile. (LoadError) 帮助我解决这个问题。Ruby-2.6.0 和 rails 5.2.4.2

标签: ruby-on-railspostgresqlactiverecordpgcrypto

解决方案


我查看了 gem“pgcrypto”,我不确定它是否执行在 Postgres 数据库中安装扩展所需的“创建扩展”行。您可以尝试在您的数据库中运行它吗?开发和测试?

CREATE EXTENSION IF NOT EXISTS pgcrypto;

推荐阅读