代码如下: require 'rubygems' require 'active_record'
ActiveRecord::Base.establish_connection( :adapter => "sqlite3" , :database => "db/development.sqlites3" )
class Product < ActiveRecord::Base end
人生最曼妙的风景,竟是内心的淡定与从容!
我剛好做了類似的事情,給你參考:
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代码]
你確定資料庫裡有這個表?
rake 資料庫:建立 rake 資料庫:遷移
我剛好做了類似的事情,給你參考:
你確定資料庫裡有這個表?
rake 資料庫:建立
rake 資料庫:遷移