feat: customized page 404
This commit is contained in:
parent
fe508c0a73
commit
7dcd4ba538
11 changed files with 149 additions and 77 deletions
|
@ -419,6 +419,17 @@ class ApplicationController < ActionController::Base
|
|||
prepend_view_path "app/custom_views"
|
||||
end
|
||||
|
||||
def try_nav_bar_profile_from_referrer
|
||||
# detect context from referer, simple (no detection when refreshing the page)
|
||||
params = Rails.application.routes.recognize_path(request&.referer)
|
||||
|
||||
controller_class = "#{params[:controller].camelize}Controller".safe_constantize
|
||||
return if controller_class.nil?
|
||||
|
||||
controller_instance = controller_class.new
|
||||
controller_instance.try(:nav_bar_profile)
|
||||
end
|
||||
|
||||
# Extract a value from params based on the "path"
|
||||
#
|
||||
# params: { dossiers: { champs_public_attributes: { 1234 => { value: "hello" } } } }
|
||||
|
|
9
app/controllers/errors_controller.rb
Normal file
9
app/controllers/errors_controller.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ErrorsController < ApplicationController
|
||||
def nav_bar_profile = try_nav_bar_profile_from_referrer
|
||||
|
||||
def not_found
|
||||
render(status: 404)
|
||||
end
|
||||
end
|
|
@ -21,16 +21,7 @@ class ReleaseNotesController < ApplicationController
|
|||
render "scrollable_list" if params[:page].present?
|
||||
end
|
||||
|
||||
def nav_bar_profile
|
||||
# detect context from referer, simple (no detection when refreshing the page)
|
||||
params = Rails.application.routes.recognize_path(request&.referer)
|
||||
|
||||
controller_class = "#{params[:controller].camelize}Controller".safe_constantize
|
||||
return if controller_class.nil?
|
||||
|
||||
controller_instance = controller_class.new
|
||||
controller_instance.try(:nav_bar_profile)
|
||||
end
|
||||
def nav_bar_profile = try_nav_bar_profile_from_referrer
|
||||
|
||||
private
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue