开源项目railscasts有用户模型(链接到完整文件)
class User < ActiveRecord::Base
........
def generate_token
if token.blank? # where's definition of this variable?
characters = ('a'..'z').to_a + ('A'..'Z').to_a + ('1'..'9').to_a
begin
self.token = Array.new(32) { characters.sample }.join
end while self.class.exists?(:token => token)
end
end
end
请解释一下变量token
来自哪里?这个变量的定义在哪里?