The situation:
merb 1.0.12 updated to merb 1.1 so as to be able to use the bundler
and current rubygems
merb 1.1 needs dm 0.10.1
models no longer function with dm 0.10.1.

== code start ==

class I90Ctlfil
  include DataMapper::Resource

  property :id    , Serial
  property :ctlidz, Discriminator, :index => true
  property :ctlcdz, String       , :index => true, :length => 20
  property :ctlsdz, Date         , :index => true
  property :ctledz, Date
  property :ctldsz, String       , :length => 30
  property :ctlxxz, String       , :length => 256
end
class Kyrmanuf < I90Ctlfil
  def self.get_points(underwriter, risk, year)
    year = year.to_i
    rows = self.all(:fields => [:ctlcdz, :ctlxxz, :ctlsdz], :order =>
[:ctlcdz.asc], :ctlcdz.like => "#{underwriter}#{risk}%")
    return nil if rows.nil?
    rows.each_with_index do |row, i|
      if i <= rows.size-2
        return row.ctlxxz[0,2].to_i - row.ctlxxz[2,2].to_i if year >=
row.ctlcdz[5,4].to_i and year < rows[i+1].ctlcdz[5,4].to_i
      else
        return row.ctlxxz[0,2].to_i - row.ctlxxz[2,2].to_i
      end
    end
  end
end

== code end ==

Kyrmanuf.get_points(underwriter, risk, year)
fails with "can't modify frozen object - (TypeError)"
on
return nil if rows.nil?

This is not complicated code, I just want to know if I got any results...

ok so I replaced
return nil if rows.empty?
with
p rows
and the error in full is

merb : worker (port 4000) ~ can't modify frozen object - (TypeError)
project/gems/gems/dm-core-0.10.1/lib/dm-core/resource.rb:491:in
`original_attributes'
project/gems/gems/dm-core-0.10.1/lib/dm-core/resource.rb:90:in `key'
project/gems/gems/dm-core-0.10.1/lib/dm-core/resource.rb:89:in `map'
project/gems/gems/dm-core-0.10.1/lib/dm-core/resource.rb:89:in `key'
project/gems/gems/dm-core-0.10.1/lib/dm-core/collection.rb:1208:in
`resource_added'
project/gems/gems/dm-core-0.10.1/lib/dm-core/collection.rb:1228:in
`resources_added'
project/gems/gems/dm-core-0.10.1/lib/dm-core/collection.rb:1228:in `each'
project/gems/gems/dm-core-0.10.1/lib/dm-core/collection.rb:1228:in
`resources_added'
project/gems/gems/dm-core-0.10.1/lib/dm-core/collection.rb:480:in `concat'
project/gems/gems/dm-core-0.10.1/lib/dm-core/collection.rb:1008:in `lazy_load'
project/gems/gems/extlib-0.9.13/lib/extlib/lazy_array.rb:451:in `map'
project/gems/gems/dm-core-0.10.1/lib/dm-core/collection.rb:902:in `inspect'
project/app/models/i90_ctlfils/kyrmanuf.rb:18:in `p'
project/app/models/i90_ctlfils/kyrmanuf.rb:18:in `get_points'

For now I'm just going to ditch dm and go couchdb/couchrest so i can
get on with this project (all the data I'm interacting with in
dm/mysql is read-only, write/read is in couchdb/couchrest)
Maybe someone will offer a simple solution and I can go back to the
dm/couch branch of my project.
Git branching ftw :)

Nick

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to