Skip to content

Instantly share code, notes, and snippets.

@slaskis
Created Oct 13, 2009
Embed
What would you like to do?
require 'rubygems'
require 'dm-core'
class Event
include DataMapper::Resource
default_scope.update( :order => [ :start_time.desc ] )
property :id, Serial
property :eid, String
property :name, String, :length => 255
property :tagline, String, :length => 255
property :start_time, Integer
property :end_time, Integer
property :location, String, :length => 255
property :description, Text
end
DataMapper::Logger.new(STDOUT)
DataMapper.setup(:default, "sqlite3::memory:")
DataMapper.auto_migrate!
Event.create( :eid => "abc" )
Event.create( :eid => "def" )
Event.create( :eid => "abc" )
p Event.all( :fields => [:eid] , :unique => true )
# => TypeError: can't modify frozen object
p Event.all( :fields => [:id,:eid] , :unique => true )
# Works!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment