I'm trying to create a utility to copy a subset of records from a single table of one PostgreSQL database to that same table in another PostgreSQL database. I'm doing this with dynamic subclassing, but it's not working: it raises the error "xxx database is not configured" (where xxx is my database URL, something like "postgres://username:password@computername:5432/databasename". I know the URL is good because I copied it from my Heroku configuration and I am able to access the database from pgAdmin3 on my local machine. Here's the code:
我正在尝试创建一个实用程序,将一个PostgreSQL数据库的单个表中的记录子集复制到另一个PostgreSQL数据库中的同一个表中。我正在使用动态子类化,但它不起作用:它引发错误“xxx数据库未配置”(其中xxx是我的数据库URL,类似于“postgres:// username:password @computername:5432 / databasename”我知道URL很好,因为我从Heroku配置中复制了它,我可以从本地机器上的pgAdmin3访问数据库。这是代码:
puts "Enter the database URL"
url = gets.chomp
db_conn = Class.new(ActiveRecord::Base) do
establish_connection url
end
1 个解决方案
#1
0
Support for establish_connection(url) was added in Rails 3.2; I was running Rails 3.1.3.
在Rails 3.2中添加了对establish_connection(url)的支持;我正在运行Rails 3.1.3。
#1
0
Support for establish_connection(url) was added in Rails 3.2; I was running Rails 3.1.3.
在Rails 3.2中添加了对establish_connection(url)的支持;我正在运行Rails 3.1.3。