#493 ✓resolved

Double before/after hook call craziness.

Reported by coryodaniel | July 30th, 2008 @ 10:46 PM

Ok... This is weird and I dont really understand what is happening.

Say you have the following classes:

class User

include DataMapper::Resource

#*** etc, etc ***

before :save do

puts "saving"



require "lib/path/to/user"

class UserSettings

include DataMapper::Resource

#*** etc, etc ***


Given that everything is great, but when you have something like a Dir glob that auto requires all of your classes

Dir.glob("my glob").each {|f| require f}

The double require for user:

1. in the glob

2. in the UserSettings

This does some crazyness. The users class registers each of its before/after callbacks on each require...

Thus, if I do:

user = User.new


It would output:



Worse yet, if my after :create were to oh, say create another record in another table, it would create two...

Comments and changes to this ticket

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.

New-ticket Create new ticket

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