Skip to content

Instantly share code, notes, and snippets.

Created June 11, 2010 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/434783 to your computer and use it in GitHub Desktop.
Save anonymous/434783 to your computer and use it in GitHub Desktop.
require 'active_record'
puts 'password please'
pass=gets.chomp
ActiveRecord::Base.establish_connection(:adapter => 'postgresql',
:host => 'foo',
:username => 'foo',
:password => pass,
:database => 'foo')
#Created with:
#CREATE TABLE demos
#(
# id uuid NOT NULL,
# data text,
# CONSTRAINT demos_pkey PRIMARY KEY (id)
#)
class Demo < ActiveRecord::Base
end
#so we don't error out if the script is run multiple times
Demo.delete_all
demo1=Demo.new(:data=>'foo')
demo2=Demo.new(:data=>'bar')
demo1.id='36d171f1-cd53-440e-bca7-1281753a5545'
demo2.id='bd816883-c774-4497-9cfe-1105208a58d4'
demo1.save
demo2.save
puts Demo.find('bd816883-c774-4497-9cfe-1105208a58d4').data
puts Demo.find('36d171f1-cd53-440e-bca7-1281753a5545').data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment