class Project < ActiveRecord::Base has_many :tasks def self.all_names find(:all).collect(&:name) end end一个&符号后面跟着一个名字叫做to_proc,是rails对ruby的一点功能补充。