diff --git a/app/controllers/habits_controller.rb b/app/controllers/habits_controller.rb index bff97460204ac910b0e97f4947dba580708dc37c..f05194d5823b252569436858050dbb3e6a0927ab 100644 --- a/app/controllers/habits_controller.rb +++ b/app/controllers/habits_controller.rb @@ -85,8 +85,10 @@ class HabitsController < ApplicationController format.html { redirect_to :root, notice: 'You have already done that today. Come back tomorrow!' } end end - - if @habit.streak > @habit.max_streak || @habit.max_streak.nil? + if @habit.max_streak.nil? + @habit.max_streak = @habit.streak + @habit.save + elsif @habit.streak > @habit.max_streak @habit.max_streak = @habit.streak @habit.save end