Shortcut Blocks with Symbol to_proc 通过to_proc为代码块逻辑命名

class Project < ActiveRecord::Base
  has_many :tasks

  def self.all_names
    find(:all).collect(&:name)
  end
end
一个&符号后面跟着一个名字叫做to_proc,是rails对ruby的一点功能补充。
posted @ 2015-10-13 22:31  Jacky_Kun  阅读(128)  评论(0编辑  收藏  举报