Does a class in RoR automatically initiate the first method when a new object of that class is created?
class User
attr_accessor :name, :email
def initialize(attributes = {})
@name = attributes[:name]
@email = attributes[:email]
end
def formatted_email
"#{@name} <#{@email}>"
end
end
Say I create a new User like this
connor = User.new(name: "Connor B", email: "CB@example.com")
How does it know to automatically start the first method but the second method only works when called upon?