Subashini Kumar wrote: > Hi, > I am new to Rails.I tried developing a basic quiz application.Please > help me out in my doubt.Thanks in advance > > <% CODE %> > > class QuizController < ApplicationController > > def index > # i have retrieved the first five questions from the database for > displaying the #question to user > @quiz=Quiz.find(:all,:limit=>5)
You should really call this variable @quizzes, so it will be clear that it contains an Array of Quiz objects, not just one. > > end > > def report > > end > > # this method checks the answer and gives score > def checkanswer > # here i want to access the @quiz object which is a set of questions i > have #retreived from the database.Hot to access it? You'll need to retrieve the records again, or pass them in from params or the session. Instance variables do not persist between controller method calls (because the controller is freshly instantiated each time a request is made). > end > > end Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

