use rails action_name & controller_name methods (#2666)

Co-authored-by: Ahmad Farhat <ahmad.af.farhat@gmail.com>
This commit is contained in:
Mohamad Abras
2021-04-17 21:35:52 +03:00
committed by GitHub
parent 5eea14a780
commit 81c9e7db10
5 changed files with 14 additions and 21 deletions

View File

@ -58,18 +58,11 @@ module ApplicationHelper
# Returns 'active' if the current page is the users home page (used to style header)
def active_home
home_actions = %w[show cant_create_rooms]
return "active" if params[:controller] == "admins" && params[:action] == "index" && current_user.has_role?(:super_admin)
return "active" if params[:controller] == "rooms" && home_actions.include?(params[:action])
return "active" if controller_name == "admins" && action_name == "index" && current_user.has_role?(:super_admin)
return "active" if controller_name == "rooms" && home_actions.include?(action_name)
""
end
# Returns the action method of the current page
def active_page
route = Rails.application.routes.recognize_path(request.env['PATH_INFO'])
route[:action]
end
def role_colour(role)
role.colour || Rails.configuration.primary_color_default
end