0
这是在最近Railscast一些代码:如何告诉Ruby类和实例方法的区别
class UserMailer < ActionMailer::Base
default from: "[email protected]"
def password_reset(user)
@user = user
mail :to => user.email, :subject => "Password Reset"
end
end
,这是在控制器
def create
user = User.find_by_email(params[:email])
UserMailer.password_reset(user).deliver
redirect_to :root, :notice => "Email sent with password reset instructions."
end
的password_reset
方法看起来像一个实例方法给我,但它看起来像它被称为类方法。它是一个实例还是一个类的方法,或者这个类有什么特别之处?
啊是的源代码---我必须记住..谢谢.. –