<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -22,27 +22,29 @@ class AttendanceController &lt; ApplicationController
   # this method is similar to batch, but does not clear all the existing records for the group first
   # this method also allows you to record attendance for people not in the database (used for checkin 'add a friend' feature)
   def create
-    @group = Group.find(params[:group_id])
+    @group = params[:group_id].to_i &gt; 0 ? Group.find(params[:group_id]) : nil
     @attended_at = Time.parse(params[:attended_at])
     if @group.admin?(@logged_in)
       params[:ids].to_a.each do |id|
         if person = Person.find_by_id(id)
           AttendanceRecord.delete_all([&quot;person_id = ? and attendance_records.attended_at = ?&quot;, id, @attended_at])
-          @group.attendance_records.create!(
-            :person_id      =&gt; person.id,
-            :attended_at    =&gt; @attended_at,
-            :first_name     =&gt; person.first_name,
-            :last_name      =&gt; person.last_name,
-            :family_name    =&gt; person.family.name,
-            :age            =&gt; person.age_group,
-            :can_pick_up    =&gt; person.can_pick_up,
-            :cannot_pick_up =&gt; person.cannot_pick_up,
-            :medical_notes  =&gt; person.medical_notes
-          )
+          if @group
+            @group.attendance_records.create!(
+              :person_id      =&gt; person.id,
+              :attended_at    =&gt; @attended_at,
+              :first_name     =&gt; person.first_name,
+              :last_name      =&gt; person.last_name,
+              :family_name    =&gt; person.family.name,
+              :age            =&gt; person.age_group,
+              :can_pick_up    =&gt; person.can_pick_up,
+              :cannot_pick_up =&gt; person.cannot_pick_up,
+              :medical_notes  =&gt; person.medical_notes
+            )
+          end
         end
       end
       # record attendance for a person not in database (one at a time)
-      if person = params[:person]
+      if person = params[:person] and @group
         @group.attendance_records.create!(
           :attended_at    =&gt; @attended_at,
           :first_name     =&gt; person['first_name'],
@@ -51,7 +53,13 @@ class AttendanceController &lt; ApplicationController
         )
       end
       respond_to do |format|
-        format.html { redirect_to group_attendance_index_path(@group, :attended_at =&gt; @attended_at) }
+        format.html do
+          if @group
+            redirect_to group_attendance_index_path(@group, :attended_at =&gt; @attended_at)
+          else
+            render :text =&gt; 'Attendance saved.', :layout =&gt; true
+          end
+        end
         format.json { render :text =&gt; {'status' =&gt; 'success'}.to_json }
       end
     else</diff>
      <filename>app/controllers/attendance_controller.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3ed65587f40100fd70a5673f38a26886b78a5ef3</id>
    </parent>
  </parents>
  <author>
    <name>Tim Morgan</name>
    <email>tim@timmorgan.org</email>
  </author>
  <url>http://github.com/seven1m/onebody/commit/fb61370ae684a5e1621b09037cf1ca8d6b1eb905</url>
  <id>fb61370ae684a5e1621b09037cf1ca8d6b1eb905</id>
  <committed-date>2009-10-20T21:21:47-07:00</committed-date>
  <authored-date>2009-10-20T21:21:47-07:00</authored-date>
  <message>Don't fail on attendance on group_id=0.</message>
  <tree>58457b709547c482e0c3161d46e4911c9ccafdde</tree>
  <committer>
    <name>Tim Morgan</name>
    <email>tim@timmorgan.org</email>
  </committer>
</commit>
