Sha256: de51619c39de7feb0135c830cc7b594721595621861d53fdac4ebc3359d24dc7

Contents?: true

Size: 788 Bytes

Versions: 4

Compression:

Stored size: 788 Bytes

Contents

module Zertico
  class Responder
    module ForceRedirect
      def initialize(controller, resources, options={})
        super
        @force_redirect = options.delete(:force_redirect)
      end

      protected

      def navigation_behavior(error)
        if get?
          raise error
        elsif has_errors? && default_action
          if @force_redirect
            controller.flash.keep
            redirect_to navigation_location
          else
            controller.flash.clear
            render :action => default_action
          end
        else
          controller.flash.keep
          redirect_to navigation_location
        end
      end

      def set_flash_message?
        return @force_redirect unless @force_redirect.nil?
        super
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zertico-2.0.0.beta.1 lib/zertico/responder/force_redirect.rb
zertico-2.0.0.alpha.3 lib/zertico/responder/force_redirect.rb
zertico-2.0.0.alpha.2 lib/zertico/responder/force_redirect.rb
zertico-2.0.0.alpha.1 lib/zertico/responder/force_redirect.rb