I am using Rails 2.3.2 and I am really miss something important in here.
I got some .rb files in my lib folder and in one of them, I got a line saying
User.new(x,y,z)
But when I go to the user.rb which is also sitting in lib folder, I don’t find any method with defined with new. When I look at the initializer, it just assigns the incoming attributes to the variables like
def initialize(x,y,z)
@x = x
@y = y
@z = z
end
Can you guys please tell me what I am really missing here. I know I am missing something really important.
Thanks
In Ruby (not only Rails) calling
ClassName.new()invokesinitializemethod from this class to … well.. initialize the object created. Theinitializemethod will be passed all the arguments that are passed tonew()See here for details: http://ruby-doc.org/docs/ProgrammingRuby/html/tut_classes.html