ruby - 请高手帮看看这个问题,脱离Rails使用ActiveRecord出现Could not find table 'products'的错误
黄舟
黄舟 2017-04-21 10:56:59
0
3
762

代码如下:
require 'rubygems'
require 'active_record'

ActiveRecord::Base.establish_connection(
:adapter => "sqlite3" ,
:database => "db/development.sqlites3"
)

class Product < ActiveRecord::Base
end

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

Antworte allen(3)
巴扎黑

我正好做了类似的事情,给你参考:

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 db:create
rake db:migrate

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage