title: Creating a countdown timer in Rails that resets on the backend
body: <p>I am currently creating a Rails quiz application with a timer that counts down the seconds left to answer the question. </p>
  
  <p>In my first version, I did this a simple way: creating a variable for the timer, an instance for seconds, and then making it part of the quiz's Javascript, like so: </p>
  
  <pre><code>Quiz = function() {
    this.quizCurrent = 0;
    this.score = 0;
    this.seconds = 10;
    this.timing = this.seconds;
    this.container = $('#trivia');
    this.participationId = null;
   }
  
   Quiz.prototype.init = function() {
    $('#trivia').on('click', '.btn.btn-primary-questions', this.checkAnswer.bind(this));
    $('div.timer strong').text(this.seconds)
  
    this.start();
   }
  </code></pre>
  
  <p>I would now like to move this to the backend using Rails. A previous question references the <a href="https://github.com/jnbt/countdown">countdown gem</a>, but that seems to present two issues: </p>
  
  <p>1) I will need to repeatedly call the date/time and validate for each question (which I don't think I can do with countdown), and;</p>
  
  <p>2) I ideally could then pass this value into the Javascript as a variable. </p>
  
  <p>In the documentation for that gem, it shows how you can pass the countdown time into the view directly. However, I am using the countdown value (in other words, when it hits zero) to force the user to the next question while recording a wrong answer, like below, as part of my validation: </p>
  
  <pre><code>Quiz.prototype.timer = function() {
   var that = this;
  
   this.timing--;
     $('div.timer strong').text(this.timing);
     if (this.timing &lt;= 0) {
       self.stop(); 
    $.getJSON('/api/skip_question/' + this.participationId, function() {
      that.nextQuestion();
     })
    }}
  </code></pre>
  
  <p>Any ideas on how I can "check" the time on the backend while still having the quiz check to make sure time hasn't run out?</p>