hi,
  i got the following error while update records, Please help me why i
got this error and also i attach my sample code in bottom of error
message.

/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/associations/
one_to_many.rb:302:in `save_resource': undefined method
`attach_parent' for #<DataMapper::Associations::RelationshipChain:
0xb7751fa4> (NoMethodError)
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/relationship.rb:172:in `with_repository'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
support/kernel.rb:6:in `repository'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core.rb:
181:in `repository'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
repository.rb:44:in `scope'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core.rb:
181:in `repository'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
support/kernel.rb:6:in `repository'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/relationship.rb:172:in `with_repository'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/one_to_many.rb:298:in `save_resource'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/one_to_many.rb:210:in `save'
        from /usr/lib/ruby/gems/1.8/gems/extlib-0.9.13/lib/extlib/
lazy_array.rb:452:in `each'
        from /usr/lib/ruby/gems/1.8/gems/extlib-0.9.13/lib/extlib/
lazy_array.rb:452:in `each'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/one_to_many.rb:309:in `send'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/one_to_many.rb:309:in `method_missing'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/one_to_many.rb:210:in `save'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
resource.rb:301:in `hookable__save_nan_before_advised'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
resource.rb:301:in `each'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
resource.rb:301:in `hookable__save_nan_before_advised'
        from /usr/lib/ruby/gems/1.8/gems/extlib-0.9.13/lib/extlib/
hook.rb:299:in `save'
        from /usr/lib/ruby/gems/1.8/gems/extlib-0.9.13/lib/extlib/
hook.rb:297:in `catch'
        from /usr/lib/ruby/gems/1.8/gems/extlib-0.9.13/lib/extlib/
hook.rb:297:in `save'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/one_to_many.rb:303:in `save_resource'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/relationship.rb:172:in `with_repository'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
support/kernel.rb:6:in `repository'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core.rb:
181:in `repository'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
repository.rb:44:in `scope'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core.rb:
181:in `repository'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
support/kernel.rb:6:in `repository'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/relationship.rb:172:in `with_repository'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/one_to_many.rb:298:in `save_resource'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/one_to_many.rb:210:in `save'
        from /usr/lib/ruby/gems/1.8/gems/extlib-0.9.13/lib/extlib/
lazy_array.rb:452:in `each'
        from /usr/lib/ruby/gems/1.8/gems/extlib-0.9.13/lib/extlib/
lazy_array.rb:452:in `each'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/one_to_many.rb:309:in `send'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/one_to_many.rb:309:in `method_missing'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
associations/one_to_many.rb:210:in `save'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
resource.rb:301:in `hookable__save_nan_before_advised'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
resource.rb:301:in `each'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
resource.rb:301:in `hookable__save_nan_before_advised'
        from /usr/lib/ruby/gems/1.8/gems/extlib-0.9.13/lib/extlib/
hook.rb:299:in `save'
        from /usr/lib/ruby/gems/1.8/gems/extlib-0.9.13/lib/extlib/
hook.rb:297:in `catch'
        from /usr/lib/ruby/gems/1.8/gems/extlib-0.9.13/lib/extlib/
hook.rb:297:in `save'
        from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/
resource.rb:538:in `update_attributes'
        from sample_datamapper.rb:75


my example code is

require 'rubygems'
require 'dm-core'

DataMapper.setup( :default, "sqlite3:///home/abs1/sample2/test1.db" )

class Commit
   include DataMapper::Resource
    property :id,           Integer,  :serial => true
    property :identifier,   String,   :nullable => false
    property :message,      String,   :length => 255
    property :author,       String,   :length => 255
    property :committed_at, DateTime
    property :created_at,   DateTime
    property :updated_at,   DateTime
    has 1,     :build,   :class_name => "Build",
                          :order => [:created_at.desc]
end

class Build
   include DataMapper::Resource
    property :id,           Integer,  :serial => true
    property :output,       Text,     :default => "", :lazy => false
    property :successful,   Boolean,  :default => false
    property :commit_id,    Integer,  :nullable => false
    property :created_at,   DateTime
    property :updated_at,   DateTime
    property :started_at,   DateTime
    property :completed_at, DateTime
    has n, :buildsteps, :class_name => "BuildStep"
    has n, :steps, :through => :buildsteps, :mutable => true
end

class Step
  include DataMapper::Resource
     has n, :buildsteps, :class_name => "BuildStep"
     has n, :builds, :through => :buildsteps, :mutable => true
     property :id,           Integer,  :serial => true
     property :name,         String
     property :dsp_name,     String
     property :dsp_order,    Integer
     property :created_at,   DateTime
     property :updated_at,   DateTime
end

class
BuildStep
  include
DataMapper::Resource
     belongs_to :build, :class_name => "Build", :child_key =>
[:build_id]
     belongs_to :step, :class_name => "Step", :child_key =>
[:step_id]
     property :id, Integer, :serial => true
     property :started_at,   DateTime
     property :completed_at, DateTime
     property :output,       Text
     property :successful,   Boolean
     property :created_at,   DateTime
     property :updated_at,   DateTime
end

DataMapper.auto_migrate!
build = Build.new(:commit_id => 2, :output => "rake aboted" )
commit = Commit.create(:identifier => '0782', :author =>
'sankar', :message => "rake file added")
commit.update_attributes(:build => build)
build = commit.build

Step.create(:name => 'rake unit')
Step.create(:name => 'rake integration')
Step.create(:name => 'rake features')

Step.all.each { |steps|
  BuildStep.create(:step => steps, :build => build)
}

build.steps

commit.update_attributes(:committed_at => Time.now)

--

You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to datamap...@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.


Reply via email to