diff --git a/app/helpers/habits_helper.rb b/app/helpers/habits_helper.rb index 67af8d55c5..373fb18648 100644 --- a/app/helpers/habits_helper.rb +++ b/app/helpers/habits_helper.rb @@ -11,18 +11,19 @@ module HabitsHelper end end - def vote_link(habit, state) - case state - when 'up' - return unless habit.up - text,dir,style = "+","up","up" - when 'down' - return unless habit.down - text,dir,style = "-","down","down" - when 'checked' then text,dir,style = "[ ]","up","check" - when 'unchecked' then text,dir,style = "[X]","down","check" + def vote_link(habit, direction=nil) + if direction=='up' + return unless habit.up + text,dir,style = "+","up","up" + elsif direction=='down' + return unless habit.down + text,dir,style = "-","down","down" + elsif habit.done + text,dir,style = "[X]","down","check" + else + text,dir,style = "[ ]","up","check" end - return link_to(text, { :action => "vote", :id => habit.id, :vote => 'dir' }, :class=>style, :remote=>true) + return link_to(text, { :action => "vote", :id => habit.id, :vote => dir }, :class=>style, :remote=>true) end end diff --git a/app/views/habits/index.html.erb b/app/views/habits/index.html.erb index 4124d800d1..cc5ad121b2 100644 --- a/app/views/habits/index.html.erb +++ b/app/views/habits/index.html.erb @@ -2,9 +2,12 @@ <%= link_to 'New Habit', new_habit_path %>
| Habits | +Daily | +
|---|---|
- Habits
|
- Daily
|