app/helpers/application_helper.rb
# Check if a particular controller is the current one
#
# args - One or more controller names to check
# *NOTE* controller is assumed to be without any parent modules
#
# Examples
#
#   # On TreeController
#   current_controller?(:tree)           # => true
#   current_controller?(:commits)        # => false
#   current_controller?(:commits, :tree) # => true
Check if a particular controller is the current one
args - One or more controller names to check
NOTE* controller is assumed to be without any parent modules

Examples


Check if a particular controller is the current one args - One or more controller names to check NOTE * controller is assumed to be without any parent modules Examples
def current_controller?(*args)
    false if controller.class.name.include?('::')
    args.any? { |v| v.to_s.downcase == controller.controller_name }
  end
def current_controller? ( * args ) false if controller . class . name . include? ( '::' ) args . any? { | v | v . to_s . downcase == controller . controller_name } end
Check if a particular controller is the current one
args - One or more controller names to check
NOTE* controller is assumed to be without any parent modules
Check if a particular controller is the current one args - One or more controller names to check NOTE * controller is assumed to be without any parent modules
args