Created
January 3, 2013 06:03
-
-
Save anonymous/4441176 to your computer and use it in GitHub Desktop.
An attempt to find a failing case with string keys.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'dm-core' | |
require 'uuid' | |
require_relative 'lib/dm-redis-adapter/adapter.rb' | |
DataMapper.setup(:default, {:adapter => "redis"}) | |
class Zone | |
include DataMapper::Resource | |
property :id, String, :key => true, :unique_index => true, :default => lambda { |x,y| UUID.new.generate } | |
property :preview_mode, Boolean, :default => false | |
has 1, :campaign | |
end | |
class Campaign | |
include DataMapper::Resource | |
property :id, String, :key => true, :unique_index => true, :default => lambda { |x,y| UUID.new.generate } | |
property :name, String | |
belongs_to :zone | |
end | |
DataMapper.finalize | |
z = Zone.create | |
c = Campaign.create(:name => "The light on the Bosporus", :zone => z) | |
puts Campaign.first.zone | |
puts Zone.first.campaign.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment