Forum: Ruby on Rails Class definition OK?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sean C. (Guest)
on 2006-04-06 09:03
Something's not working, and I just want to make sure that my class is
not to blame and that I've got how it works straight in my head:

The attr_reader parts make those :something (hash values, i think)
accessible as @class.something attributes outside of the class. So, once
I find the right session in the controller, I can access those values as
@session.something. Right?

For some reason I'm just getting zero for @question_total and errors for
@point_total...

class Test_session

  attr_reader :point_total
  attr_reader :question_total

  def initialize
    @point_total = 0
    @question_total = 0
  end

  def keep_score(points)
    @question_total += @question_total
    @point_total = @point_total + points
  end

end
This topic is locked and can not be replied to.