lib/datamapper4rails/restful_transactions.rb in datamapper4rail-0.1.0 vs lib/datamapper4rails/restful_transactions.rb in datamapper4rail-0.2.0
- old
+ new
@@ -9,20 +9,21 @@
base.prepend_around_filter(TransactionFilter)
end
end
class TransactionFilter
+
def self.filter(controller)
case controller.request.method
when :post, :put, :delete then
begin
+ # TODO remove the :default repository and make it more general
DataMapper::Transaction.new(DataMapper.repository(:default)) do |*block_args|
if block_given?
yield (*block_args)
# added rollback for all actions which just render
- # a page with validation errors and do not redirect to new idem potent
- # page (http-method get is idem potent within the
- # restful paradigma
+ # a page (with validation errors) and do not redirect to
+ # another page
unless controller.response.redirected_to
raise Datamapper4rails::RestfulTransactions::Rollback
end
end
end