标签:
class Project < ActiveRecord::Base has_many :tasks def self.all_names find(:all).collect(&:name) end end
一个&符号后面跟着一个名字叫做to_proc,是rails对ruby的一点功能补充。
Shortcut Blocks with Symbol to_proc 通过to_proc为代码块逻辑命名
标签:
原文地址:http://www.cnblogs.com/JackyKun/p/4876120.html