Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'ohm'
- class Change < Ohm::Model
- attribute :description
- attribute :statement
- attribute :apply_at
- attribute :created_at
- reference :creator, Person
- set :databases, Database
- index :creator_id
- end
- class Person < Ohm::Model
- attribute :name
- attribute :password
- attribute :created_at
- collection :changes, Change
- end
- class Database < Ohm::Model
- attribute :name
- attribute :hostname
- attribute :user
- attribute :password
- attribute :schema
- end
- >> c = Change[1]
- => #<Change:1 description="Test DB Query" statement="SHOW DATABASES" apply_at="Wed May 19 18:07:04 -0400 2010" created_at="Wed May 19 18:07:09 -0400 2010" creator_id="1" databases=#<Set (Database): [#<Database:1 name="QADB - iQA" hostname="qadb.ove.local" user="dbchanges" password="1audit1" schema="ove_production">]>>
- >> p = Person[1]
- => #<Person:1 name="Mark" password="password" created_at="Wed May 19 18:04:48 -0400 2010">
- >> d = Database[1]
- => #<Database:1 name="QADB - iQA" hostname="qadb.ove.local" user="dbchanges" password="1audit1" schema="ove_production">
- >> c.creator
- => #<Person:1 name="Mark" password="password" created_at="Wed May 19 18:04:48 -0400 2010">
- >> p.changes
- Ohm::Model::IndexNotFound: Ohm::Model::IndexNotFound
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:817:in `index_key_for'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:241:in `keys'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:240:in `each'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:240:in `keys'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:238:in `each'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:238:in `keys'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:237:in `tap'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:237:in `keys'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:275:in `apply'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:215:in `find'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:555:in `find'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:489:in `changes'
- from (irb):5
- >> c
- => #<Change:1 description="Test DB Query" statement="SHOW DATABASES" apply_at="Wed May 19 18:07:04 -0400 2010" created_at="Wed May 19 18:07:09 -0400 2010" creator_id="1" databases=#<Set (Database): [#<Database:1 name="QADB - iQA" hostname="qadb.ove.local" user="dbchanges" password="1audit1" schema="ove_production">]>>
- >> c.creator
- => #<Person:1 name="Mark" password="password" created_at="Wed May 19 18:04:48 -0400 2010">
- >> c.creator.changes
- Ohm::Model::IndexNotFound: Ohm::Model::IndexNotFound
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:817:in `index_key_for'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:241:in `keys'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:240:in `each'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:240:in `keys'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:238:in `each'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:238:in `keys'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:237:in `tap'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:237:in `keys'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:275:in `apply'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:215:in `find'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:555:in `find'
- from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:489:in `changes'
- from (irb):8
- >>
Add Comment
Please, Sign In to add comment