Permalink
Browse files

wip

  • Loading branch information...
1 parent 0a8b65c commit 5bf5b4bde1346db69897e88d02307b7e7f773c9b @francois committed Apr 20, 2011
Showing with 8 additions and 3 deletions.
  1. +4 −1 app/controllers/attendees_controller.rb
  2. +4 −2 app/models/event.rb
@@ -1,7 +1,10 @@
class AttendeesController < ApplicationController
def create
event = Event.find(params[:event_id])
- attendee = event.create_attendee(params[:attendee])
+ Event.transaction do
+ event.create_attendee(params[:attendee])
+ end
+
redirect_to event_path(event), :notice => "You registered for #{event.name}"
end
end
View
@@ -6,7 +6,9 @@ def build_attendee
end
def create_attendee(attrs)
- person = Person.find_or_create_by_email(attrs[:email], attrs)
- attendees.create!(:person => person)
+ Person.transaction do
+ person = Person.find_or_create_by_email(attrs[:email], attrs)
+ attendees.create!(:person => person)
+ end
end
end

0 comments on commit 5bf5b4b

Please sign in to comment.