I have my app setup to run ajax when a video is done watching. The ajax calls a User#action below. The problem is, when it is first run, it works and adds {"timestamp"=>"1"} but it never updates to {"timestamp"=>"1,1"}. Is there something I am missing? Can I not update the value in an hstore hash?
# Increases User's workouts after video is watched
def increase_workouts
@user = current_user
if logged_in?
if @user.newworkouts[Time.now.strftime("%Y%m%d").to_sym] == nil
@user.newworkouts[Time.now.strftime("%Y%m%d").to_sym] = "0"
end
@user.newworkouts[Time.now.strftime("%Y%m%d").to_sym] += "," + "1"
@user.save
render(json: { message: "Workouts increased" }, status: :ok) and return
else
render(json: { message: "Workouts increased" }, status: :ok) and return
end
end