Sha256: 7cf42678aee5cc4caeb116b7bcf38c16e442f46cc95aeae45fbd0c693fa0ec94

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 KB

Contents

module Locomotive
  module ActionController
    class PublicResponder < ::ActionController::Responder

      def navigation_behavior(error)
        if get?
          raise error
        elsif has_errors? && default_action
          # get the content entry from the controller
          entry = self.controller.instance_variable_get :@entry

          if navigation_location =~ %r(^http://)
            # simple redirection for outside urls
            redirect_to navigation_location
          else
            # render the locomotive page
            self.controller.send :render_locomotive_page, navigation_location, {
              entry.content_type.slug.singularize => entry.to_presenter(include_errors: true).as_json
            }
          end
        else
          entry = self.controller.instance_variable_get :@entry

          self.controller.flash['submitted_entry_id'] = entry.try(:_id).try(:to_s)

          # redirect to a locomotive page
          redirect_to navigation_location
        end
      end

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
locomotive_cms-2.3.1 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.3.0 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.2.3 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.2.2 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.2.1 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.2.0 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.1.4 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.1.3 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.1.2 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.1.1 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.1.0 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.0.3 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.0.2 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.0.1 lib/locomotive/action_controller/public_responder.rb
locomotive_cms-2.0.0 lib/locomotive/action_controller/public_responder.rb