- around_filter :around_action_filter
- protected
- def transaction
- ret = true
- ActiveRecord::Base.transaction do
- begin
- yield if block_given?
- rescue Exception => ex
- set_notice(ex.message)
- ret = ex.message
- raise ActiveRecord::Rollback, ex.message
- end
- end
- return ret
- end
- def around_action_filter
- return yield if request.get?
- redirect_to(:controller => "error_display", :action => "error_notice") if
- transaction { yield if block_given? } != true
- end
这是写在ApplicationController里的处理代码。其中的set_notice只是将flash[:notice]设置一下,以便在error_notice页面显示。