dataset.update(params) isn't calling after_update hook

2009-08-25 Thread Tal

Subject pretty much covers it. Running this code isn't calling the
after_update hook:

Post.filter(:id = parent_id).update(:comment_count = :comment_count
+1)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sequel-talk group.
To post to this group, send email to sequel-talk@googlegroups.com
To unsubscribe from this group, send email to 
sequel-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~--~~~~--~~--~--~---



Re: dataset.update(params) isn't calling after_update hook

2009-08-25 Thread Aman Gupta
after_update hooks are only invoked when you use Model#update, not
Dataset#update. There's no way to know which model instances were affected
by a dataset update.
  Aman

On Tue, Aug 25, 2009 at 4:06 PM, Tal swimming.b...@gmail.com wrote:


 Subject pretty much covers it. Running this code isn't calling the
 after_update hook:

 Post.filter(:id = parent_id).update(:comment_count = :comment_count
 +1)
 


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



Re: dataset.update(params) isn't calling after_update hook

2009-08-25 Thread Jeremy Evans

On Aug 25, 5:05 pm, Aman Gupta themastermi...@gmail.com wrote:
 after_update hooks are only invoked when you use Model#update, not
 Dataset#update. There's no way to know which model instances were affected
 by a dataset update.

Aman is correct.  If you want the after_update hooks run, you need to
do:

  Post.filter(:id = parent_id).all do |p|
p.update(:comment_count = p.comment_count+1)
  end

Note that that will be a lot slower than the dataset way for large
datasets.

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