From: Ilan Berci Date: 2009-09-23T22:00:57+09:00 Subject: Re: Accessing an instance variable in another method perhaps something like this.. NOT TESTED.. at work.. just pseudo code to get you started and give you ideas.. not responsible for absolutely anything including but not limited to your computer blowing up from running the code below. class QuizController < ApplicationController def index @quizes=Quiz.find(:all,:limit=>5) # TODO shake this up with a random to get unique quizes each time end def report @report = "If you aren't using ruby, you failed!" end def checkanswer @quiz = Quiz.find(params[:quiz_id]) # get the quiz from the response form answers = @quiz.answers responses = params[:responses] # get the responses from the response form @correct_answer_count = answers.zip(responses).map(0) {|sum, a, r| a == r ? sum + 1 : sum} @percentage = (@correct_answer_count / @quiz_completed.questions.size) * 100 end end Congrats on getting busy with rails, you are doing great and keep going! ilan -- Posted via http://www.ruby-forum.com/.