Heim > Fragen und Antworten > Hauptteil
代码如下:
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3" ,
:database => "db/development.sqlites3"
)
class Product < ActiveRecord::Base
end
巴扎黑2017-04-21 10:58:59
我正好做了类似的事情,给你参考:
require 'rubygems' require 'active_record' $conn_db = { :adapter => "mysql2", :host => "192.168.3.199", :database => "aaa_db", :username => "root", :password => "pppppp", :pool => 5 } class MyTable < ActiveRecord::Base establish_connection $conn_db; end .... [其他ruby代码]