Report abuse

class Consumer
  include DataMapper::Resource

  property :id, Integer, :serial => true
  property :consumer_key, String, :length => 50, :index => true
  property :request_count, Integer, :default => 0

  # Roles
  has n, :rolifications
  has n, :roles => :rolifications

end

c = Consumer.first
c.roles
#=>  [#, #]
c.parent_associations.first
=> [#, #]
c.parent_associations.first.instance_variable_get("@dirty_children")
=> nil

c.update_attributes :request_count => 1
# DataMapper::Associations::ImmutableAssociationError: You can not modify this assocation
#         from /webroot/janus_qa/releases/20080611034924/gems/gems/dm-core-0.9.1/lib/dm-core/associations/one_to_many.rb:151:in `ensure_mutable'
#         from /webroot/janus_qa/releases/20080611034924/gems/gems/dm-core-0.9.1/lib/dm-core/associations/one_to_many.rb:189:in `save_resources'
#         from /webroot/janus_qa/releases/20080611034924/gems/gems/dm-core-0.9.1/lib/dm-core/associations/one_to_many.rb:120:in `save'
#         from /webroot/janus_qa/releases/20080611034924/gems/gems/dm-core-0.9.1/lib/dm-core/repository.rb:130:in `save'
#         from /webroot/janus_qa/releases/20080611034924/gems/gems/dm-core-0.9.1/lib/dm-core/repository.rb:130:in `each'
#         from /webroot/janus_qa/releases/20080611034924/gems/gems/dm-core-0.9.1/lib/dm-core/repository.rb:130:in `save'
#         from /webroot/janus_qa/releases/20080611034924/gems/gems/dm-core-0.9.1/lib/dm-core/resource.rb:484:in `update'
#         from /webroot/janus_qa/releases/20080611034924/gems/gems/dm-core-0.9.1/lib/dm-core/resource.rb:268:in `save'
#         from /webroot/janus_qa/releases/20080611034924/gems/gems/dm-validations-0.9.1/lib/dm-validations.rb:35:in `save'
#         from /webroot/janus_qa/releases/20080611034924/gems/gems/dm-core-0.9.1/lib/dm-core/resource.rb:460:in `update_attributes'
#         from (irb):10