ITeye博客

关于returning

fei1985 · 2010-04-09 23:52 · rails · 编程语言 · Markdown

在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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。