Rumah  >  Soal Jawab  >  teks badan

ruby - 请高手帮看看这个问题,脱离Rails使用ActiveRecord出现Could not find table 'products'的错误

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

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

class Product < ActiveRecord::Base
end

黄舟黄舟2762 hari yang lalu732

membalas semua(3)saya akan balas

  • 巴扎黑

    巴扎黑2017-04-21 10:58:59

    Saya kebetulan melakukan sesuatu yang serupa, untuk rujukan anda:

    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代码]

    balas
    0
  • 迷茫

    迷茫2017-04-21 10:58:59

    Adakah anda pasti jadual ini wujud dalam pangkalan data?

    balas
    0
  • 迷茫

    迷茫2017-04-21 10:58:59

    garu db:buat
    rake db:hijrah

    balas
    0
  • Batalbalas