Skip to content
wnadeau edited this page May 24, 2011 · 1 revision

An ActiveRecord interface for SimpleDB that takes care of offsets and padding, etc. Can be used as a drop in replacement for ActiveRecord in rails.

Getting Started

  1. Install gems

gem install appoxy-aws uuidtools appoxy-simple_record

  1. Create a model

`require 'simple_record'

class MyModel < SimpleRecord::Base has_attributes :name, :age are_ints :age end` More about ModelAttributes.

  1. Setup environment

AWS_ACCESS_KEY_ID='XXXX' AWS_SECRET_ACCESS_KEY='YYYY' SimpleRecord.establish_connection(AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY) 4. Go to town

Store a model object to SimpleDB

mm = MyModel.new mm.name = "Travis" mm.age = 32 mm.save id = mm.id

Get an object from SimpleDB

mm2 = MyModel.find(id) puts 'got=' + mm2.name + ' and he/she is ' + mm.age.to_s + ' years old'

Or more advanced queries

mms = MyModel.find(:all, ["age=?", 32], :order=>"name", :limit=>10)