How to find the number of Books updated by the program in Rails
Zaw Htut Win
Posted on September 22, 2022
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 ?
💖 💪 🙅 🚩
Zaw Htut Win
Posted on September 22, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
ruby Ruby: One of the top 5 highest-paying technologies, according to Stack overflow
November 16, 2024