Establish an ActiveRecord connection with a YAML c

http://snippets.dzone.com/posts/show/6925

 

rmu_db_config.yml

host: localhost
database: xxxx
password: xxxx

 

require 'rubygems'  
require 'active_record'  

dbconfig = YAML::load(File.open('rmu_db_config.yml'))  
ActiveRecord::Base.establish_connection(dbconfig) 

class Member < ActiveRecord::Base  
end 

p participant = Member.find(:all)

 

你可能感兴趣的:(C++,c,C#,ActiveRecord,rubygems)