Skip to content

Instantly share code, notes, and snippets.

@thumblemonks
Created February 20, 2010 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thumblemonks/309894 to your computer and use it in GitHub Desktop.
Save thumblemonks/309894 to your computer and use it in GitHub Desktop.
module RiotRails
register_context_helper do
def prepare_context(description, context)
context.premium_setup { description.new } if active_record_context?(description)
context.transaction do |&original_block|
::ActiveRecord::Base.transaction do
original_block.call
raise ::ActiveRecord::Rollback
end
end
end
private
def active_record_context?(description)
description.kind_of?(Class) && description.ancestors.include?(::ActiveRecord::Base)
end
end
end # RiotRails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment