views:

23

answers:

2

i need to require active record, but I am working outside of rails (here is why: Simple Ruby Input Validation Library). do I need to require the entire rails gem, or can i be DRYer?

+2  A: 
require 'rubygems'
require 'active_record'
jordinl
+2  A: 

Here's how I'm using ActiveRecord outside of Rails:

require 'rubygems'
require 'active_record'

ActiveRecord::Base.establish_connection(
  :adapter  => "mysql",
  :database => "xxx_production",
  :username => 'root',
  :password => 'xxx',
  :host => 'localhost'
)

class Order < ActiveRecord::Base
end

Order.all.each do |o|
  ...
Paweł Gościcki