app/models/rostra/question.rb in rostra-0.1.19 vs app/models/rostra/question.rb in rostra-0.1.20
- old
+ new
@@ -1,18 +1,20 @@
module Rostra
class Question < ActiveRecord::Base
+ include Rostra::TimestampObserver
+ extend FriendlyId
+
belongs_to :user
has_many :answers, :dependent => :destroy
has_many :question_followings, :dependent => :destroy
has_many :followers, through: :question_followings, source: :user
has_many :notified_followers, through: :question_followings, source: :user,
conditions: { 'rostra_question_followings.send_email_notifications' => true }
acts_as_taggable
acts_as_voteable
is_impressionable counter_cache: { unique: true }
- extend FriendlyId
friendly_id :title, use: :slugged
validates :title, presence: true, uniqueness: true, length: { :minimum => 15 }
validates_presence_of :user, :slug, :tag_list
@@ -31,11 +33,13 @@
def answer_count
@answer_count = answers.count
end
- def unique_page_views
- impressionist_count(filter: :ip_address)
+ # The last time the question has had any activity (i.e. commment, answer, etc).
+ #
+ def active_at
+ updated_at || created_at
end
private
def create_question_following