关于returning

在beast的记录中看到一个方面中用到returning的用法。

 

 def reply(topic, body)
    returning topic.posts.build(:body => body) do |post|
      post.forum = topic.forum
      post.user  = self
      post.save
    end
  end

 有点不是很理解。在google中收到这篇文章是关于returning的说明的

http://weblog.jamisbuck.org/2006/10/27/mining-activesupport-object-returning

 

 

def returning(value)
  yield(value)
  value
end

 

你可能感兴趣的:(Google)