Allow current_controller? helper to take an Array of options

This commit is contained in:
Robert Speicher 2012-09-25 21:18:00 -04:00
parent cada511f8b
commit 60ac6a28a2
2 changed files with 12 additions and 4 deletions

View file

@ -3,13 +3,16 @@ module ApplicationHelper
# Check if a particular controller is the current one
#
# args - One or more controller names to check
#
# Examples
#
# # On TreeController
# current_controller?(:tree) # => true
# current_controller?(:commits) # => false
def current_controller?(name)
controller.controller_name == name.to_s.downcase
# current_controller?(:tree) # => true
# current_controller?(:commits) # => false
# current_controller?(:commits, :tree) # => true
def current_controller?(*args)
args.any? { |v| v.to_s.downcase == controller.controller_name }
end
def gravatar_icon(user_email = '', size = 40)