Class: Answers::Question
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Answers::Question
- Defined in:
- app/models/answers/question.rb
Instance Attribute Summary collapse
-
#tag_ids ⇒ Object
writeonly
Sets the attribute tag_ids.
Class Method Summary collapse
-
.tags ⇒ Object
returns tags in order of most taggings to least taggings.
- .tags_with_questions ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#tag_ids=(value) ⇒ Object (writeonly)
Sets the attribute tag_ids
8 9 10 |
# File 'app/models/answers/question.rb', line 8 def tag_ids=(value) @tag_ids = value end |
Class Method Details
.tags ⇒ Object
returns tags in order of most taggings to least taggings
15 16 17 |
# File 'app/models/answers/question.rb', line 15 def self. self.tag_counts_on(:tags).sort_by(&:taggings_count).reverse end |
.tags_with_questions ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/answers/question.rb', line 19 def self. = self.tag_counts_on(:tags).limit(4).order("taggings_count DESC").all = .map do |tag| { tag: tag, questions: Question.find(tag.taggings[0..3].map(&:taggable_id)) } end end |
Instance Method Details
#top_answer ⇒ Object
10 11 12 |
# File 'app/models/answers/question.rb', line 10 def top_answer self.answers.first end |