tag:blogger.com,1999:blog-5991476036615161393.post1585360143951436722..comments2010-02-05T08:15:45.256-05:00Comments on Eli Miller: Proper cache expiry with after_commitElijah Millerhttp://www.blogger.com/profile/11416221333112662701noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-5991476036615161393.post-84763991272291349332010-02-05T05:01:41.230-05:002010-02-05T05:01:41.230-05:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5991476036615161393.post-83153186259987264472010-02-04T23:25:33.433-05:002010-02-04T23:25:33.433-05:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5991476036615161393.post-85012458847836019882010-01-27T17:59:02.066-05:002010-01-27T17:59:02.066-05:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5991476036615161393.post-14369537949414579532009-06-19T07:16:01.374-05:002009-06-19T07:16:01.374-05:00If you search for
after_commit on github you will...If you search for <br /><a href="http://github.com/search?q=after_commit" rel="nofollow">after_commit on github</a> you will see there is a lot of activity around this small snippet of code.<br /><br />after_commit has been incorporated into a few projects with slight modifications. A few people have taken the idea even further and really solidified the implementation with tests for multiple record commits and the like.Elijah Millerhttps://www.blogger.com/profile/11416221333112662701noreply@blogger.comtag:blogger.com,1999:blog-5991476036615161393.post-81296093731266602592009-06-19T06:24:17.871-05:002009-06-19T06:24:17.871-05:00To make this easy to use I've made a plugin ou...To make this easy to use I've made a plugin out of the code:<br /><br /> http://github.com/craigw/callback_after_commitAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5991476036615161393.post-88438981146272965712009-02-11T15:42:00.000-05:002009-02-11T15:42:00.000-05:00In Rails 2.2 (and maybe earlier?) you can replace ...In Rails 2.2 (and maybe earlier?) you can replace the anonymous class block (the whole "class << self...end" with just "define_callbacks :after_commit"<BR/><BR/>In fact, it didn't work for me until I did this.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5991476036615161393.post-6426650764918731162007-12-13T07:42:00.000-05:002007-12-13T07:42:00.000-05:00thanks for this solution, it works like a charm (f...thanks for this solution, it works like a charm (for rails 1.2.3).. there's only one problem with it: in this implementation it's not really an after_commit, it also gets run when the save fails... If you really want this to be an after_commit, change:<BR/>callback(:after_commit)<BR/>to:<BR/>callback(:after_commit) if value<BR/>in the first method (the save without exclamation mark).. For save! this isn't necessary (if an exception is thrown, the callback call isn't reached).. For destroy i'm not too sure (i believe it always returns the object that was destroyed, unless some other custom hook-in (through alias_method_chain or anything) screws things up)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5991476036615161393.post-13600388106975119442007-06-28T02:20:00.000-05:002007-06-28T02:20:00.000-05:00Doesn't work for me with Rails 1.2.3. Goes into in...Doesn't work for me with Rails 1.2.3. Goes into infinite loops.Anonymousnoreply@blogger.com