daily pastebin goal
64%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class ResultsController < ApplicationController
  2.  
  3.   def index
  4.     @question = Question.find(params[:id])
  5.    
  6.     @options = Option.where(:question_id => params[:id])
  7.    
  8.     @total = Vote.where(:question_id => params[:id]).count
  9.    
  10.     if @total == 0
  11.       redirect_to options_path(@question)
  12.     else
  13.    
  14.       @av = 100/@total
  15.    
  16.       @optionsgraph = ""
  17.       @votesgraph = ""
  18.    
  19.       @options.each do |option|
  20.         @optionsgraph = "#{@optionsgraph}|#{option.option[0..10]}..."
  21.         @votesgraph = "#{@votesgraph},#{option.votes.count}"
  22.       end
  23.    
  24.       @optionsgraph = @optionsgraph[1..-1]
  25.       @votesgraph = @votesgraph[1..-1]
  26.    
  27.     end
  28.    
  29.     @title = @question.question + "?" # add
  30.   end
  31.  
  32. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top