Class: RatingQuestion

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_all_rating_questionsObject

Get All Rating Question



13
14
15
16
17
18
19
# File 'app/models/rating_question.rb', line 13

def self.get_all_rating_questions
  ratingQuestions = RatingQuestion.pluck(:id, :category, :question).map {|id, category, question| {id: id, category: category, question: question.upcase}}
  ratingQuestions = ratingQuestions.group_by{ |d| d[:category] }.map{|c, q| {category: c, question: q}}.take(3)
  ratingQuestions.each do |rating|
    rating[:question] = rating[:question].take(3)
  end
end

Instance Method Details

#nameObject



8
9
10
# File 'app/models/rating_question.rb', line 8

def name
  question
end