mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
Purchasing now works, refactored money to shared
This commit is contained in:
parent
ba110c7857
commit
82a343fa71
5 changed files with 20 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -52,12 +52,12 @@
|
|||
<div class="block">
|
||||
<div class='content'>
|
||||
<h2 class='title'>Rewards
|
||||
<%= render 'money'%>
|
||||
<%= render 'shared/money'%>
|
||||
</h2>
|
||||
<div class='inner'>
|
||||
<% @rewards.each do |reward| %>
|
||||
<li id="reward_<%= reward.id %>" class="reward">
|
||||
<%= link_to(image_tag('dollar.png'), { :controller=>"reward", :action => "buy", :id => reward.id }, :remote=>true) %>
|
||||
<%= link_to(image_tag('dollar.png'), { :controller=>"rewards", :action => "buy", :id => reward.id }, :remote=>true) %>
|
||||
<%= reward.name %>
|
||||
<div class='edit'>
|
||||
<%= link_to 'Edit', edit_reward_path(reward) %>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<% unless @habit.habit_type==Habit::ONE_TIME %>
|
||||
$('#habit_<%= @habit.id %>').replaceWith("<%= escape_javascript(render :partial => "habit", :locals => { :habit => @habit }) %>");
|
||||
<% end %>
|
||||
$('#progressbar').replaceWith("<%= escape_javascript(render :partial => "progressbar") %>");
|
||||
$('#money').replaceWith("<%= escape_javascript(render 'money') %>");
|
||||
$('#progressbar').replaceWith("<%= escape_javascript(render :partial => "shared/progressbar") %>");
|
||||
$('#money').replaceWith("<%= escape_javascript(render 'shared/money') %>");
|
||||
|
|
|
|||
1
app/views/rewards/buy.js.erb
Normal file
1
app/views/rewards/buy.js.erb
Normal file
|
|
@ -0,0 +1 @@
|
|||
$('#money').replaceWith("<%= escape_javascript(render 'shared/money') %>");
|
||||
Loading…
Reference in a new issue