Skip to content

Instantly share code, notes, and snippets.

@somebee
Created February 4, 2009 07:28
Show Gist options
  • Save somebee/58003 to your computer and use it in GitHub Desktop.
Save somebee/58003 to your computer and use it in GitHub Desktop.
class Location
include DataMapper::Resource
property :id, Serial
property :type, Discriminator
property :code, String, :index => true
property :name, String, :index => true, :length => 255
property :tags, Text, :lazy => false
property :description, Text, :lazy => false
property :population, Integer
property :metadata, Yaml, :lazy => false
property :depth, Integer
property :lft, Integer
property :rgt, Integer
end
class Country < Location; end
class CountryPart < Location; end
class Region < Location; end
class County < Location; end
class Municipality < Location; end
class City < Location; end
class CityPart < Location; end
class UrbanArea < Location; end
class PostalPlace < Location; end
class Street < Location; end
>> County.all.length
TypeError: can't modify frozen object
from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/collection.rb:1017:in `collection='
from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/collection.rb:1017:in `relate_resource'
from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/collection.rb:1036:in `relate_resources'
from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/collection.rb:1036:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/collection.rb:1036:in `relate_resources'
from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/collection.rb:470:in `push'
from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/collection.rb:930:in `initialize'
from /usr/local/lib/ruby/gems/1.8/gems/extlib-0.9.11/lib/extlib/lazy_array.rb:415:in `[]'
from /usr/local/lib/ruby/gems/1.8/gems/extlib-0.9.11/lib/extlib/lazy_array.rb:415:in `lazy_load'
from /usr/local/lib/ruby/gems/1.8/gems/extlib-0.9.11/lib/extlib/lazy_array.rb:7:in `length'
from (irb):1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment