Fix member creation when database is empty

This commit is contained in:
Hugo Peixoto 2023-07-11 18:50:51 +01:00
parent ae4a3c62e4
commit 5a35a72ac4

View File

@ -25,7 +25,7 @@ class MembersController < ApplicationController
# POST /members
def create
@member = Member.new(member_params.merge(number: Member.maximum(:number) + 1))
@member = Member.new(member_params.merge(number: (Member.maximum(:number) || 0) + 1))
if @member.save
@member.reset_status!