Skip to content
Browse files

Added count to top menu caption

  • Loading branch information...
1 parent 07f6db9 commit 04f7abefe435f7c50c277ff7bea0e0e4cb6f1191 Brandon Farmer committed
Showing with 8 additions and 1 deletion.
  1. +1 −1 init.rb
  2. +7 −0 lib/user_tasks_patch.rb
View
2 init.rb
@@ -15,6 +15,6 @@
description 'Allows you to maintain a personal todo list'
version '0.0.1'
- menu :top_menu, :todo_list, {:controller => 'tasks', :action => 'index'}, :caption => 'Todo List', :if => Proc.new { User.current.logged? }
+ menu :top_menu, :todo_list, {:controller => 'tasks', :action => 'index'}, :caption => Proc.new {User.current.tasks_top_menu}, :if => Proc.new { User.current.logged? }
end
View
7 lib/user_tasks_patch.rb
@@ -2,9 +2,16 @@
module UserTasksPatch
def self.included(base)
+ base.send(:include, InstanceMethods)
base.class_eval do
unloadable
has_many :tasks
end
end
+
+ module InstanceMethods
+ def tasks_top_menu
+ "Todo List (#{self.tasks.count})"
+ end
+ end
end

0 comments on commit 04f7abe

Please sign in to comment.
Something went wrong with that request. Please try again.