fix(stats): nav bar profile logic when fallbacking on referer context without request

This commit is contained in:
Colin Darie 2024-09-17 15:59:24 +02:00
parent f9994245f1
commit b68b340d81
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
3 changed files with 9 additions and 3 deletions

View file

@ -16,6 +16,12 @@ module NavBarProfileConcern
private
def nav_bar_user_or_guest
# when instanciating manually the controller (see below),
# we don't have request and current_user would fail
request && current_user ? :user : :guest
end
# Shared controllers (search, errors, release notes…) don't have specific context
# Simple attempt to try to re-use the profile from the previous page
# so user does'not feel lost.

View file

@ -87,9 +87,7 @@ module Users
retrieve_procedure
end
def nav_bar_profile
current_user ? :user : :guest
end
def nav_bar_profile = nav_bar_user_or_guest
def closing_details
@procedure = Procedure.find_by(path: params[:path])

View file

@ -2,6 +2,8 @@
module Users
class StatistiquesController < ApplicationController
def nav_bar_profile = nav_bar_user_or_guest
def statistiques
@procedure = procedure
return procedure_not_found if @procedure.blank? || @procedure.brouillon?