Use ActiveRecord ouside of Rails

Tagged with Ruby ActiveRecord

Language: Ruby

View as text

# require AR
require 'rubygems'
require 'active_record'

# connect to the database (sqlite in this case)
ActiveRecord::Base.establish_connection({
      :adapter => "sqlite", 
      :dbfile => "db/database.sqlite"
})

#define a migration
class BuildDatabase < ActiveRecord::Migration
  def self.up

  end

  def self.down

  end
end

BuildDatabase.up


# define a simple model 
class Task < ActiveRecord::Base
end


Last updated at 13:53 PM on Aug 08, 2008 by Brian Hogan

SnippetStash costs money to host and develop. The service is free for everyone to use
but if you found it useful please consider making a small donation.