How can you call class methods on mailers when they're not defined as such?
问题 When sending mail in Rails, usually one would do something like this: UserMailer.password_reset(user).deliver But if we look inside UserMailer we can see this: def password_reset(user) # not self.password_reset # ... end Notice that the method name is not prefixed with self . Looking at it, it seems like you need to instantiate the object first as below. How does Rails do this? UserMailer.new.password_reset(user).deliver 回答1: That's a great question. In the source (https://github.com/rails