mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-15 12:07:43 +00:00
Restrict reward if too expensive
This commit is contained in:
parent
6a7fa90cc4
commit
a929724857
2 changed files with 11 additions and 3 deletions
|
|
@ -65,8 +65,12 @@ class RewardsController < ApplicationController
|
|||
|
||||
def buy
|
||||
@reward = current_user.rewards.find(params[:id])
|
||||
current_user.money -= @reward.value
|
||||
current_user.save
|
||||
@too_expensive = true
|
||||
if current_user.money > @reward.value
|
||||
current_user.money -= @reward.value
|
||||
current_user.save
|
||||
@too_expensive = false
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
# format.html { render action: "edit" }
|
||||
|
|
|
|||
|
|
@ -1 +1,5 @@
|
|||
$('#money').replaceWith("<%= escape_javascript(render 'shared/money') %>");
|
||||
<% if @too_expensive %>
|
||||
$('#money').effect("pulsate", 100);
|
||||
<% else %>
|
||||
$('#money').replaceWith("<%= escape_javascript(render 'shared/money') %>");
|
||||
<% end %>
|
||||
|
|
|
|||
Loading…
Reference in a new issue