Postgres has many functions available for use. In this example we will look at how to utilize one of these functions in ActiveRecord. This formula will return the age not the date of post. The method age() is now added to the Post model.

posts ='*, age(created_at))
posts.each { |f| puts f.age }


Leave a Reply

Your email address will not be published. Required fields are marked *