Add current_controller? helper method

Simplifies some of the "active tab" checks we're doing
This commit is contained in:
Robert Speicher 2012-09-25 19:22:44 -04:00
parent 95f0a41141
commit 3ad931ca92
2 changed files with 25 additions and 0 deletions

View file

@ -1,6 +1,17 @@
require 'digest/md5'
module ApplicationHelper
# Check if a particular controller is the current one
#
# Examples
#
# # On TreeController
# current_controller?(:tree) # => true
# current_controller?(:commits) # => false
def current_controller?(name)
controller.controller_name == name.to_s.downcase
end
def gravatar_icon(user_email = '', size = 40)
if Gitlab.config.disable_gravatar? || user_email.blank?
'no_avatar.png'