I'm trying to connect my Rails app to an EC2 instance that contains a PG database. I've already checked with Navicat that I can connect to the database given the EC2 details. The issue is that when run locally the Rails app can't be viewed; it throws the error "database configuration does not specify adapter". A similar issue is thrown when I try a database migration. I haven't even tried to push this up to my Rails EC2 since it isn't working locally.
我正在尝试将我的Rails应用程序连接到包含PG数据库的EC2实例。我已经使用Navicat检查过,鉴于EC2的详细信息,我可以连接到数据库。问题是当在本地运行时,无法查看Rails应用程序;它抛出错误“数据库配置没有指定适配器”。尝试数据库迁移时会抛出类似的问题。我甚至都没有试过把它推到我的Rails EC2上,因为它不能在本地工作。
My database.yml file looks like this:
我的database.yml文件如下所示:
production:
adapter: postgresql
encoding: unicode
database: postgres
host: ec2-54-197-115-117.compute-1.amazonaws.com
pool: 10
port: 5432 (have both included and removed this line)
username: a database username for security
password: the password associated with that user
My gem files include the gem pg.
我的宝石文件包括gem pg。
For the database name I just wrote what it had in Navicat, but perhaps there's an official name associated with it I should be using; if so, how would I find it? The host I got from the EC2 details. And the username and password were the ones I set with the postgres database via unix.
对于数据库名称,我刚刚写了它在Navicat中的内容,但也许我应该使用它的正式名称;如果是的话,我怎么找到它?我从EC2细节中得到的主持人。用户名和密码是我通过unix在postgres数据库中设置的用户名和密码。
Thanks in advance for any insight!
提前感谢任何见解!
Edit:
Fixed!
1 个解决方案
#1
2
Fixed! I had forgotten to create an actual DB after setting up the PG; I changed the name in my database.yml file to reflect the new db name. Also, I needed to set on my Rails app environment directly (I thought Apache did this automatically w/Passenger) with "export RAILS_ENV=production". I thought it was still broken when I restarted my server and nothing had changed, but I just had to restart the console. Hope this helps someone else out too!
固定!设置PG后,我忘了创建一个实际的DB;我在database.yml文件中更改了名称以反映新的数据库名称。此外,我需要直接在我的Rails应用程序环境中设置(我认为Apache会自动使用Passenger),并使用“export RAILS_ENV = production”。当我重新启动服务器并且没有任何改变时,我认为它仍然坏了,但我只需要重新启动控制台。希望这也有助于其他人!
#1
2
Fixed! I had forgotten to create an actual DB after setting up the PG; I changed the name in my database.yml file to reflect the new db name. Also, I needed to set on my Rails app environment directly (I thought Apache did this automatically w/Passenger) with "export RAILS_ENV=production". I thought it was still broken when I restarted my server and nothing had changed, but I just had to restart the console. Hope this helps someone else out too!
固定!设置PG后,我忘了创建一个实际的DB;我在database.yml文件中更改了名称以反映新的数据库名称。此外,我需要直接在我的Rails应用程序环境中设置(我认为Apache会自动使用Passenger),并使用“export RAILS_ENV = production”。当我重新启动服务器并且没有任何改变时,我认为它仍然坏了,但我只需要重新启动控制台。希望这也有助于其他人!