每当创建一个 DataMapper 类的实例时,如何在它被销毁之前执行一个块?
问问题
155 次
1 回答
4
假设通过创建和销毁你的意思是从数据库中插入和删除......
从文档
class Post
include DataMapper::Resource
# ... key and properties here
# This record will save properly
before :create do |post|
true
end
# But it will not be destroyed
before :destroy do |post|
throw :halt
end
end
于 2010-02-08T04:17:50.120 回答