aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/new_base/base.rb
blob: 313b9a5e1f13f4a148b982f976a86c950759552c (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
module ActionController
  class Base < Http
    abstract!
    
    use AbstractController::Callbacks
    use AbstractController::Helpers
    use AbstractController::Logger

    use ActionController::HideActions
    use ActionController::UrlFor
    use ActionController::Renderer
    use ActionController::Layouts
    use ActionController::ConditionalGet
    
    # Legacy modules
    include SessionManagement
    include ActionDispatch::StatusCodes
    
    # Rails 2.x compatibility
    use ActionController::Rails2Compatibility
    
    def self.inherited(klass)
      ::ActionController::Base.subclasses << klass.to_s
      super
    end
    
    def self.subclasses
      @subclasses ||= []
    end
    
    def self.app_loaded!
      @subclasses.each do |subclass|
        subclass.constantize._write_layout_method
      end
    end
    
    def render(action = action_name, options = {})
      if action.is_a?(Hash)
        options, action = action, nil 
      else
        options.merge! :action => action
      end
      
      super(options)
    end
    
    def render_to_body(options = {})
      options = {:template => options} if options.is_a?(String)
      super
    end
    
    def process_action
      ret = super
      render if response_body.nil?
      ret
    end
    
    def respond_to_action?(action_name)
      super || view_paths.find_by_parts?(action_name.to_s, {:formats => formats, :locales => [I18n.locale]}, controller_path)
    end
  end
end