Let's say I have a script running and I want to find the last updated isbn number of the book during the run time with rails console.
Book.where(updated_at:Book.maximum('updated_at')).first.isbn
Then I can find how many books are updated during the runtime with this enhanced query
Book.pluck('isbn').uniq.find_index(Book.where(updated_at:Book.maximum('updated_at')).first.isbn)+1
Neat! Isn't it ?
Top comments (0)