Add current_action? helper

This commit is contained in:
Robert Speicher 2012-09-26 15:06:07 -04:00
parent afc4a75499
commit aa0c4b77b6
2 changed files with 34 additions and 0 deletions

View file

@ -1,4 +1,5 @@
require 'digest/md5'
module ApplicationHelper
# Check if a particular controller is the current one
@ -15,6 +16,20 @@ module ApplicationHelper
args.any? { |v| v.to_s.downcase == controller.controller_name }
end
# Check if a partcular action is the current one
#
# args - One or more action names to check
#
# Examples
#
# # On Projects#new
# current_action?(:new) # => true
# current_action?(:create) # => false
# current_action?(:new, :create) # => true
def current_action?(*args)
args.any? { |v| v.to_s.downcase == action_name }
end
def gravatar_icon(user_email = '', size = 40)
if Gitlab.config.disable_gravatar? || user_email.blank?
'no_avatar.png'