Skip to content

Instantly share code, notes, and snippets.

@larsklevan
Created June 7, 2011 21:02
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 larsklevan/1013155 to your computer and use it in GitHub Desktop.
Save larsklevan/1013155 to your computer and use it in GitHub Desktop.
Rollback changes to DB during email preview
module EmailPreview
class << self
def preview_with_rollback(*args)
mail = nil
ActiveRecord::Base.transaction do
mail = preview_without_rollback *args
raise ActiveRecord::Rollback, "Let's not and say we did"
end
mail
end
alias_method_chain :preview, :rollback
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment