logger 中使用 block 有什么神奇之处?
“we can pass in a block to the debug call. This means that the code will only be called if the logging level is set to debug.”
def index
@articles = Article.all
logger.debug { "Articles Count: #{Article.count}" }
end
原文在这篇文章的底部,我彻底没看懂 http://railscasts.com/episodes/56-the-logger-revised?view=asciicast