Sha256: e40aa667c8857846cd82becad8eae8bb9edbd44f80553a1b7f5ab66befd98f41

Contents?: true

Size: 571 Bytes

Versions: 6

Compression:

Stored size: 571 Bytes

Contents

module Rostra
  class Answer < ActiveRecord::Base
    include Rostra::EmailNotifier
    include Rostra::TimestampObserver

    belongs_to :question
    belongs_to :user

    acts_as_voteable
    acts_as_commentable

    validates :text, :presence => true

    before_save :create_question_following

    attr_accessor :follow_by_email

    private

    def create_question_following
      opted_not_to_follow = follow_by_email.to_i.zero?
      unless opted_not_to_follow || question.followers.exists?(user)
        question.followers << user
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rostra-0.1.25 app/models/rostra/answer.rb
rostra-0.1.24 app/models/rostra/answer.rb
rostra-0.1.23 app/models/rostra/answer.rb
rostra-0.1.22 app/models/rostra/answer.rb
rostra-0.1.21 app/models/rostra/answer.rb
rostra-0.1.20 app/models/rostra/answer.rb