How do I inspect what was the last failed job in Resque?

resque, ruby-on-rails

Solution

With `Resque::Failure.all(0, 20)` you will give 1st param as the start point and second param as the number of results.

Resque::Failure.all(0, 1)

is the correct syntax to get the last failure, if they are ordered DESC

EDIT:

They are ordered ASC, so:

Resque::Failure.all((Resque::Failure.count - 1), 1)

Problem

I know it returns a hash, but its strange how the syntax goes.. I'm trying to find out what the last one is. If I do this : ``` Resque.info[:failed] # -> 68 ``` So assuming there's 68 failed jobs, when I do this : ``` Resque::Failure.all() ``` It only returns one job ( I believe its the first job ). I think this is just a syntactical error on my part. Because I've also seen this : ``` Resque::Failure.all(0, 20) ``` Which I believe would pull an array of indices between 0 and 20. So.. anyone know the syntactical clause to pull just the last failed job?

Original source