给定以下代码:
def create
@something = Something.new(params[:something])
thing = @something.thing # another model
# modification of attributes on both 'something' and 'thing' omitted
# do I need to wrap it inside a transaction block?
@something.save
thing.save
end
将 create 方法隐式包装在 ActiveRecord 事务中,还是需要将其包装到事务块中?如果我确实需要包装它,这是最好的方法吗?