Browse Source

Prevent crash on invalid 'edit' of Activity

Maarten van den Berg 7 years ago
parent
commit
6a71a2288e
1 changed files with 6 additions and 0 deletions
  1. 6 0
      app/controllers/activities_controller.rb

+ 6 - 0
app/controllers/activities_controller.rb

42
 
42
 
43
   # GET /activities/1/edit
43
   # GET /activities/1/edit
44
   def edit
44
   def edit
45
+    set_edit_parameters!
46
+  end
47
+
48
+  # Shared lookups for rendering the edit-view
49
+  def set_edit_parameters!
45
     @non_organizers = @activity.participants.where(is_organizer: [false, nil])
50
     @non_organizers = @activity.participants.where(is_organizer: [false, nil])
46
     @organizers = @activity.organizers
51
     @organizers = @activity.organizers
47
 
52
 
100
         }
105
         }
101
         format.json { render :show, status: :ok, location: @activity }
106
         format.json { render :show, status: :ok, location: @activity }
102
       else
107
       else
108
+        set_edit_parameters!
103
         format.html { render :edit }
109
         format.html { render :edit }
104
         format.json { render json: @activity.errors, status: :unprocessable_entity }
110
         format.json { render json: @activity.errors, status: :unprocessable_entity }
105
       end
111
       end