forked from fixin.me/fixin.me
Allow specifying navigation tab for controllers
This commit is contained in:
@@ -7,6 +7,7 @@ class ApplicationController < ActionController::Base
|
||||
# used, or custom layout method needs to be defined.
|
||||
|
||||
helper_method :current_user_disguised?
|
||||
helper_method :current_tab
|
||||
|
||||
before_action :authenticate_user!
|
||||
|
||||
@@ -42,6 +43,16 @@ class ApplicationController < ActionController::Base
|
||||
new_user_session_path
|
||||
end
|
||||
|
||||
class << self
|
||||
attr_reader :navigation_menu_tab
|
||||
def navigation_tab(name)
|
||||
@navigation_menu_tab = name.to_s
|
||||
end
|
||||
end
|
||||
def current_tab
|
||||
self.class.navigation_menu_tab || controller_name
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def rescue_turbo(exception)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class Units::DefaultsController < ApplicationController
|
||||
navigation_tab :units
|
||||
|
||||
before_action except: :index do
|
||||
raise AccessForbidden unless current_user.at_least(:admin)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user