From 54a798eb12b5c2b9558598629bc2ecd875ef8dbf Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Mon, 27 May 2013 17:58:57 -0700 Subject: [PATCH] Add Topic#age_in_days for determining age of topic --- app/models/topic.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/topic.rb b/app/models/topic.rb index 5f5b8c0bddc..57acf234fb1 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -193,6 +193,10 @@ class Topic < ActiveRecord::Base @post_numbers ||= posts.order(:post_number).pluck(:post_number) end + def age_in_days + ((Time.zone.now - created_at) / 1.day).round + end + def has_meta_data_boolean?(key) meta_data_string(key) == 'true' end