diff --git a/app/controllers/habits_controller.rb b/app/controllers/habits_controller.rb index 32575479fb..05daba8648 100644 --- a/app/controllers/habits_controller.rb +++ b/app/controllers/habits_controller.rb @@ -8,7 +8,6 @@ class HabitsController < ApplicationController @habits = current_user.habits.where(:habit_type => Habit::ALWAYS) @daily = current_user.habits.where(:habit_type => Habit::DAILY) @one_time = current_user.habits.where(:habit_type => Habit::ONE_TIME).where(:done=>false) - @score = current_user.habits.sum('score').to_i respond_to do |format| format.html # index.html.erb @@ -98,7 +97,6 @@ class HabitsController < ApplicationController @habit.user=current_user @habit.vote(params[:vote]) - @score = current_user.habits.sum('score').to_i respond_to do |format| # format.html { render action: "edit" } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be7945c..3e2eb974d5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,6 @@ module ApplicationHelper + + def score + current_user.habits.sum('score').to_i + end end diff --git a/app/views/habits/completed.erb b/app/views/habits/completed.erb index a526ce6c23..048f400c6c 100644 --- a/app/views/habits/completed.erb +++ b/app/views/habits/completed.erb @@ -1,9 +1,4 @@ -<% content_for :score do %> - <%= render :partial => "progressbar", :locals => { :score => @score } %> -<% end %> - - -<%= link_to 'New Habit', new_habit_path %> +<%= link_to 'Back', habits_url %> diff --git a/app/views/habits/index.html.erb b/app/views/habits/index.html.erb index 728b2a4e60..ae675e63c1 100644 --- a/app/views/habits/index.html.erb +++ b/app/views/habits/index.html.erb @@ -1,8 +1,3 @@ -<% content_for :score do %> - <%= render :partial => "progressbar", :locals => { :score => @score } %> -<% end %> - - <%= link_to 'New Habit', new_habit_path %>
@@ -50,6 +45,7 @@ + <%= link_to 'View Completed', :action=>'completed' %>
diff --git a/app/views/habits/vote.js.erb b/app/views/habits/vote.js.erb index 518d1d55e6..e2d46a4687 100644 --- a/app/views/habits/vote.js.erb +++ b/app/views/habits/vote.js.erb @@ -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", :locals => { :score => @score }) %>"); +$('#progressbar').replaceWith("<%= escape_javascript(render :partial => "progressbar") %>"); $('#money').replaceWith("<%= escape_javascript(render 'money') %>"); diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 16d72dc1c2..fd7c858b4d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,7 +10,7 @@