On 22 June 2011 06:36, John SB <[email protected]> wrote: > Thanks for that, I simplified things a bit for the post. There is > actually a reason to have an explicit status. > > I'm going ahead with adding the after_find callback but I think I've > run into another issue. > > I was thinking I would do the following in after_find when I detected > an expired message. > > Change its status to expired. > Save It > Return false. > > I was thinking returning false would result in the find not returning > that result. But it still seems to be returning it. I couldn't find > anything online that really explained what is supposed to happen when > you return false in this callback. Any ideas?
I presume here you are trying to get round the problem that if a find is performed with a condition of !expired then the find should somehow reject the record after setting it to expired. I had not thought of that complication. In particular if the find is for a set of records then the changed records must be removed from the collection. I don't know how to do that. Any suggestions from the more experienced here? Colin > > On Jun 20, 6:53 am, Colin Law <[email protected]> wrote: >> On 20 June 2011 09:15, John Feminella <[email protected]> wrote: >> >> >> def expired? >> >> Time.now - self.created_at > 10.days # or whatever the period is >> >> end >> >> > fwiw, I prefer to write that sort of condition as: >> >> > ===== >> > def expired? >> > self.created_at < 10.days.ago >> > end >> > ===== >> >> Yes, much better, I had forgotten about ago. >> >> Colin > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" 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/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" 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/rubyonrails-talk?hl=en.

