当前位置: 代码迷 >> Web前端 >> 非WEB程序中施用Active Record
  详细解决方案

非WEB程序中施用Active Record

热度:714   发布时间:2012-10-18 13:46:56.0
非WEB程序中使用Active Record

一、新建一个Ruby文件

?

require "rubygems" 
require "active_record" 

ActiveRecord::Base.establish_connection(:adapter => "oracle", :database => "test_development", :username => "root", :password => "root", :host => "localhost")  
   
class Entry < ActiveRecord::Base  
    
end 

entry = Entry.find(1)  
puts entry.title # Good Life with happy heart

?

二、Rails项目根目录中新建一个Ruby文件

?

require "../config/environment.rb" 

entry = Entry.find(1)  
puts entry.title # Good Life with happy heart

?

  相关解决方案