Commit b1ce210

mo khan <mo@mokhan.ca>
2017-02-11 22:27:54
within_transaction
1 parent 77bc181
app/controllers/application_controller.rb
@@ -16,4 +16,11 @@ class ApplicationController < ActionController::Base
   def record_not_found
     render text: "404 Not Found", status: 404
   end
+
+  def within_transaction
+    ActiveRecord::Base.transaction do
+      yield
+    end
+  end
 end
+
app/controllers/registrations_controller.rb
@@ -1,4 +1,6 @@
 class RegistrationsController < PublicController
+  around_action :within_transaction, only: :create
+
   def new
     @user = User.new
   end