On Jun 22, 3:29 am, Colin Law <[email protected]> wrote:
> 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?

If it's absolutely necessary to have an explicit status, I'd typically
do this with a cron script that expires messages at a sensible
frequency (nightly, perhaps?) as expiring them on-load (as you've
noticed) is going to make an epic mess - not only will collection
finds not work right, but simple stuff like "count the number of
active messages" will be harder than needed.

--Matt Jones

-- 
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.

Reply via email to