Skip to content

Commit 7c4b03a

Browse files
committed
Fix: bug when you try to add empty organiser to chapter
I added validation in the organisers controller to show a message if user tried to click add organiser without selecting one from the dropdown
1 parent 03b0800 commit 7c4b03a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

app/controllers/admin/chapters/organisers_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ def index
1212
def create
1313
authorize :organiser
1414

15+
if params[:organiser].blank? || params[:organiser][:organiser].blank?
16+
flash[:alert] = 'Please select a member to make organiser.'
17+
redirect_to admin_chapter_organisers_path(@chapter) and return
18+
end
19+
1520
member = Member.find(params[:organiser][:organiser])
1621
member.add_role(:organiser, @chapter)
1722

app/views/admin/chapters/organisers/index.html.haml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
.container.py-4.py-lg-5.organisers
2+
- if flash[:notice]
3+
.alert.alert-success= flash[:notice]
4+
- if flash[:alert]
5+
.alert.alert-danger= flash[:alert]
26
.row.mb-4
37
.col
48
%h1

0 commit comments

Comments
 (0)