非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

?

那段雨骤风狂。人生之旅本就是风雨兼程,是要说曾经拥有,

非WEB程序中使用Active Record

相关文章:

你感兴趣的文章:

标签云: