aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/base.rb
blob: 10244f8216dfe7b611ea13546a6273a79c9e1096 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
module ActionController
  class Base < Metal
    abstract!

    include AbstractController::Callbacks
    include AbstractController::Layouts
    include AbstractController::Translation

    include ActionController::Helpers
    
    include ActionController::HideActions
    include ActionController::UrlFor
    include ActionController::Redirecting
    include ActionController::Rendering
    include ActionController::Renderers::All
    include ActionController::ConditionalGet
    include ActionController::RackDelegation
    include ActionController::Configuration

    # Legacy modules
    include SessionManagement
    include ActionController::Caching
    include ActionController::MimeResponds

    # Rails 2.x compatibility
    include ActionController::Compatibility

    include ActionController::Cookies
    include ActionController::Flash
    include ActionController::Verification
    include ActionController::RequestForgeryProtection
    include ActionController::Streaming
    include ActionController::HttpAuthentication::Basic::ControllerMethods
    include ActionController::HttpAuthentication::Digest::ControllerMethods

    # Add instrumentations hooks at the bottom, to ensure they instrument
    # all the methods properly.
    include ActionController::Instrumentation

    # TODO: Extract into its own module
    # This should be moved together with other normalizing behavior
    module ImplicitRender
      def send_action(*)
        ret = super
        default_render unless response_body
        ret
      end

      def default_render
        render
      end

      def method_for_action(action_name)
        super || begin
          if template_exists?(action_name.to_s, {:formats => formats}, :_prefix => controller_path)
            "default_render"
          end
        end
      end
    end

    include ImplicitRender

    include ActionController::Rescue

    def self.inherited(klass)
      ::ActionController::Base.subclasses << klass.to_s
      super
      klass.helper :all
    end

    def self.subclasses
      @subclasses ||= []
    end

    # This method has been moved to ActionDispatch::Request.filter_parameters
    def self.filter_parameter_logging(*args, &block)
      ActiveSupport::Deprecation.warn("Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set 'config.filter_parameters' in config/application.rb instead", caller)
      filter = Rails.application.config.filter_parameters
      filter.concat(args)
      filter << block if block
      filter
    end

  protected

    # Overwrite url rewriter to use request.
    def _url_rewriter
      return ActionController::UrlRewriter unless request
      @_url_rewriter ||= ActionController::UrlRewriter.new(request, params)
    end
  end
end