Please don't judge me too harshly because I am so new to this topic that I don't know how to ask the question (or what to search to get answers):
I am learning nested forms in Sinatra, but encountered something I don't understand which relates to Ruby.
See the code snippet below--while trying to test the code in rake console, I typed in Team, and was surprised to see an object created with the name "Team". But if I type in my_team = Team.new(params), I get an error message that undefined local variable or method 'params' for main:Object
If I typed in anything else, say 'man', I get NameError: undefined local variable or method 'man' for main:Object
Why does the name of the class result in an instance of the class? Shouldn't it require Class_name.new to create an object?
class Team
attr_accessor :name
TEAM = []
def initialize(params)
@name = params[:team][:name]
TEAM << self
end
def self.all
TEAM
end
end