I think you want to use dm-adjust. It's designed for setting counter columns, and shouldn't have this issue.
On Dec 15, 2008, at 7:28 PM, Pedro Belo <[email protected]> wrote: > > Hey guys, > > I'm new to DataMapper, so I'm probably doing something wrong heh. But > anways: > > I need to cache the number of associated instances for one model. I > did something like: > > class Company > def cache_employee_count > self.employee_count = employees.size > save > end > end > > And this method is called by the after :save hook in the associated > model, like: > > class Employee > after :save do > company.cache_employee_count > end > end > > But when I run this thing I get an infinite loop, because > cache_employee_count is triggering the after :save block in the > Employee class, even though I'm not changing any employee. Is that > expected? How can I work around this? > > Thanks! > Pedro > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
