Forum: Ruby on Rails Error: Called id for nil, which would mistakenly be 4

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.
Zhao Y. (Guest)
on 2009-01-21 04:53
I define a class:

class BuildLogger
  @@build_logger=nil

  def self.get_build_logger(file_name=nil)
    if @@build_logger == nil      ###this line will thrown an error
      @@build_logger=Logger.new("build_logger")
      @@build_logger.level = DEBUG
    end
    return @@build_logger
  end
end

I invoke BuildLogger.get_build_logger in a controller. An error "Called
id for nil, which would mistakenly be 4 -- if you really wanted the id
of nil, use object_id" is always thrown on the "if" line. I have no idea
about this error. does anyone know this problem?
This topic is locked and can not be replied to.