Today I Learned

hashrocket A Hashrocket project

Use .first! and .last! ActiveRecord Finder Methods

Today I learned there are accompanying ! methods for .first and .last finder methods.

As you might expect, these methods raise an ActiveRecord::RecordNotFound if there is no first or last record to be found.

Docs

h/t Craig Hafer

See More #rails TILs
Looking for help? Hashrocket has been an industry leader in Ruby on Rails since 2008. Rails is a core skill for each developer at Hashrocket, and we'd love to take a look at your project. Contact us and find out how we can help you.