Access denied, Please sign in and make sure you have proper permission.
RT
其实我想问两个内容
- 能不能在 rails 项目启动时就连接两个数据库,一个是存储自己数据的 mysql,另外一个是其他系统的 oracle 数据库
- 假如是一般的 Ruby 程序连接 oracle 的话,该用哪个 gem 呢,或者谁直接贴我点代码也行
谢谢
在 database.yml 里添加另一组配置 记好了名字 然后 model 这样写
class OtherRecord < ActiveRecord::Base
establish_connection :other
end
#1 楼 @zj0713001 请问我这样连一个 oracle,连接成功了,defect.all
也有内容了
但是Defect.where(:defect_id=>123).bg_summary
却显示bg_summary
为undefined method
请问我漏了什么?
谢谢
qc:
adapter: oracle_enhanced
host: 123.123.123.123
encoding: utf8
database: db
username: system
password: system
port: 1521
class Defect < ActiveRecord::Base
establish_connection :qc
self.table_name='bug'
end
gem 'activerecord-oracle_enhanced-adapter', '~> 1.4.0'
gem 'ruby-oci8', '~> 2.1.0'
#3 楼 @zhbinx 如果是表里的字段 因为你 where 出来的不是一个对象 而是一个对象列表 所以假如你的 defect_id 可以确定单个记录的话 推荐用 Defect.find_by_defect_id(123).bg_summary
这样能直接调用