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