Created
June 29, 2014 16:16
-
-
Save barek2k2/00e027cf4b18fa464a66 to your computer and use it in GitHub Desktop.
question model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Question < ActiveRecord::Base | |
scope :start_questions, -> { where(start: true) } | |
def end_question? | |
self.next_question_id_for_yes.nil? && self.next_question_id_for_no.nil? | |
end | |
def start_question? | |
self.start? | |
end | |
def next_question_for(answer) | |
next_question_id = self.send("next_question_id_for_#{answer}".to_sym) | |
Question.find(next_question_id) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment