ruby sinatra activerecord
如果是用 require “sinatra” require “active_record”
require ‘mysql2’ 用底下設定比較快 ActiveRecord::Base.configurations = YAML.load_file(‘database.yml’) ActiveRecord::Base.establish_connection(‘production’)
用 require “sqlite3” ActiveRecord::Base.establish_connection( :adapter => ‘sqlite3’, :database => ‘blog.db’ )
注意:database.yml 要像底下,關健字不一樣,就不能用
production: adapter: mysql2 database: host: localhost username: password: