Class: Question

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/question.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.crd_per_pageObject



33
34
35
# File 'app/models/question.rb', line 33

def self.crd_per_page
  5
end

Instance Method Details

#answer_bodyObject



37
38
39
40
41
42
43
44
# File 'app/models/question.rb', line 37

def answer_body
  text = ""
  self.reload
  self.answers.each do |answer|
    text += answer.body
  end
  return text
end

#last_updated_atObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/question.rb', line 50

def last_updated_at
  if answers.last
    time = answers.last.updated_at
  end
  if time
    if time > updated_at
      time
    else
      updated_at
    end
  else
    updated_at
  end
end

#usernameObject



46
47
48
# File 'app/models/question.rb', line 46

def username
  self.user.try(:username)
end