
saving in an after :save doesn't save when creating a new obj
Reported by Gary Yngve | December 12th, 2009 @ 08:24 PM
!/usr/bin/env ruby
require 'rubygems'
gem 'dm-core', '~>0.10.2'
require 'dm-core'
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, 'sqlite3::memory:')
class Foo
include DataMapper::Resource
property :id, Serial property :num, Integer
after :save do
self.num = 42
save
end end
DataMapper.auto_migrate!
f = Foo.create(:num=>7)
puts f.num # prints 42
puts Foo.first.num # prints 7, should print 42
f.save # ugh, it wasn't saved after the hook!!!
puts Foo.first.num # prints 42
Comments and changes to this ticket
-
Dan Kubb (dkubb) February 5th, 2010 @ 02:51 AM
- State changed from new to duplicate
This is the same problem as #1152
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
People watching this ticket
Referenced by
-
1152 trying to trigger an additional save (without validations / callbacks) inside an after :save callback This is similar to #1153 too.