我如何转换(这有效):
desc "Import Bar"
task :import_bar => :environment do
OCI8.new('user', 'pass', 'database').exec('select foo from bar') do |r|
puts r
end
end
这样的事情(不工作):
desc "Import Bar"
task :import_bar => :environment do
ActiveRecord::Base.connection.execute('select foo from bar') do |r|
puts r
end
end
的database.yml
development:
adapter: oracle_enhanced
database: database
username: user
password: pass
pool: 5
timeout: 5000
rake import_bar
无输出
答案 0 :(得分:1)
您忘记使用fetch迭代对象,请尝试:
desc "Import Bar"
task :import_bar => :environment do
ActiveRecord::Base.connection.execute('select foo from bar').fetch() do |r|
r.join(',')
end
end