Files
openfoodnetwork/app/reflexes/application_reflex.rb
David Cook 0f46da07b2 Render flashes along with table
It doesn't matter where the flash messages appear in the HTML (thanks to fixed positioning), so why not keep it simple and send them with the main response.

preventDefault in case we are inside a form, so the button doesn't submit it.
2023-12-06 15:13:15 +11:00

28 lines
704 B
Ruby

# frozen_string_literal: true
class ApplicationReflex < StimulusReflex::Reflex
# Put application-wide Reflex behavior and callbacks in this file.
#
# Learn more at: https://docs.stimulusreflex.com/rtfm/reflex-classes
#
# For code examples, considerations and caveats, see:
# https://docs.stimulusreflex.com/rtfm/patterns#internationalization
include CanCan::ControllerAdditions
delegate :current_user, to: :connection
before_reflex do
I18n.locale = current_user.locale
end
private
def current_ability
Spree::Ability.new(current_user)
end
def morph_admin_flashes
morph "#flashes", render(partial: "admin/shared/flashes", locals: { flashes: flash })
end
end