ビデオが見終わったときにajaxを実行するように私のアプリケーションをセットアップしました。 ajaxは以下のUser#アクションを呼び出します。問題は、最初に実行されたときに動作し、{"timestamp" => "1"}追加されますが、{"timestamp" => "1,1"}には更新されません。私が紛失しているものはありますか? hstoreハッシュの値を更新できないのですか?hstoreのハッシュ値にRailsアプリケーションのために追加
# 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