1. Nifty ActiveRecord methods you may or may not have known about.

    I was browsing through the Rails RDocs today to get some background on a method I wanted to use and happened to notice a couple of methods I had never even seen before that look pretty handy.

    Maybe I’m way behind the curve here, so if you know about these then good work. Otherwise, maybe my pointing them out will help bring them out of obscurity and into more use. Without further ado:

    Person.maximum(‘age’) => 93

    Person.minimum(‘age’) => 7

    Pretty good. Pret-ty, pret-ty, pret-ty good.

    Find these and some other helpful methods for doing database calculations here http://api.rubyonrails.org/classes/ActiveRecord/Calculations/ClassMethods.html#M002187

    Text
    8 months ago