Sha256: fc8f1c471d565a7bc44cd4c6062adc3ab414c5b65286eb242d1887819ea86cdb
Contents?: true
Size: 916 Bytes
Versions: 4
Compression:
Stored size: 916 Bytes
Contents
require_relative "inertia_rails" module InertiaRails module Controller extend ActiveSupport::Concern included do before_action do # :inertia_errors are deleted from the session by the middleware InertiaRails.share(errors: session[:inertia_errors]) if session[:inertia_errors].present? end end module ClassMethods def inertia_share(**args, &block) before_action do InertiaRails.share(**args) if args InertiaRails.share_block(block) if block end end end def inertia_location(url) headers['X-Inertia-Location'] = url head :conflict end def redirect_to(options = {}, response_options = {}) if (inertia_errors = response_options.fetch(:inertia, {}).fetch(:errors, nil)) session[:inertia_errors] = inertia_errors end super(options, response_options) end end end
Version data entries
4 entries across 4 versions & 1 rubygems