diff --git a/app/controllers/rewards_controller.rb b/app/controllers/rewards_controller.rb index a655408846..ff25997c4f 100644 --- a/app/controllers/rewards_controller.rb +++ b/app/controllers/rewards_controller.rb @@ -61,4 +61,19 @@ class RewardsController < ApplicationController format.json { head :no_content } end end + + + def buy + @reward = current_user.rewards.find(params[:id]) + current_user.money -= @reward.value + current_user.save + + respond_to do |format| + # format.html { render action: "edit" } + # format.json { render json: @habit.errors, status: :unprocessable_entity } + format.js + end + end + + end diff --git a/app/views/habits/index.html.erb b/app/views/habits/index.html.erb index f896a354a3..79ba6385ba 100644 --- a/app/views/habits/index.html.erb +++ b/app/views/habits/index.html.erb @@ -52,12 +52,12 @@