github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

rails / rails

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 4,957
    • 827
  • Source
  • Commits
  • Network (827)
  • Downloads (61)
  • Wiki (4)
  • Graphs
  • Tree: beca1f2

click here to add a description

click here to add a homepage

  • Branches (6)
    • 1-2-stable
    • 2-0-stable
    • 2-1-stable
    • 2-2-stable
    • 2-3-stable
    • master
  • Tags (61)
    • v3.0.0.beta1
    • v2.3.5
    • v2.3.4
    • v2.3.3.1
    • v2.3.3
    • v2.3.2.1
    • v2.3.2
    • v2.3.1
    • v2.3.0
    • v2.2.3
    • v2.2.2
    • v2.2.1
    • v2.2.0
    • v2.1.2
    • v2.1.1
    • v2.1.0_RC1
    • v2.1.0
    • v2.0.5
    • v2.0.4
    • v2.0.3
    • v2.0.2
    • v2.0.1
    • v2.0.0_RC2
    • v2.0.0_RC1
    • v2.0.0_PR
    • v2.0.0
    • v1.2.6
    • v1.2.5
    • v1.2.4
    • v1.2.3
    • v1.2.2
    • v1.2.1
    • v1.2.0_RC2
    • v1.2.0_RC1
    • v1.2.0
    • v1.1.6
    • v1.1.5
    • v1.1.4
    • v1.1.3
    • v1.1.2
    • v1.1.1
    • v1.1.0_RC1
    • v1.1.0
    • v1.0.0
    • v0.14.4
    • v0.14.3
    • v0.14.2
    • v0.14.1
    • v0.13.1
    • v0.13.0
    • v0.12.0
    • v0.11.1
    • v0.11.0
    • v0.10.1
    • v0.10.0
    • v0.9.5
    • v0.9.4.1
    • v0.9.4
    • v0.9.3
    • v0.9.2
    • v0.9.1
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Ruby on Rails — Read more

  cancel

http://rubyonrails.org

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Template#mime_type should not use Mime::Type when Action Controller is not 
included 
lifo (author)
Sun Feb 01 16:21:03 -0800 2009
commit  beca1f2e151558ded3d5a4efebd328ab2533edc6
tree    d4a4f38597811c13b5b8cda254f008ca58473723
parent  ed5fa2fe339e0aabde657ffdec24ac591d390d73
rails / actionpack / lib / action_controller / dispatcher.rb actionpack/lib/action_controller/dispatcher.rb
100644 117 lines (98 sloc) 3.95 kb
edit raw blame history
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
module ActionController
  # Dispatches requests to the appropriate controller and takes care of
  # reloading the app after each request when Dependencies.load? is true.
  class Dispatcher
    class << self
      def define_dispatcher_callbacks(cache_classes)
        unless cache_classes
          # Development mode callbacks
          before_dispatch :reload_application
          after_dispatch :cleanup_application
 
          ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = false
        end
 
        if defined?(ActiveRecord)
          after_dispatch :checkin_connections
          to_prepare(:activerecord_instantiate_observers) { ActiveRecord::Base.instantiate_observers }
        end
 
        after_dispatch :flush_logger if Base.logger && Base.logger.respond_to?(:flush)
 
        to_prepare do
          I18n.reload!
        end
      end
 
      # DEPRECATE: Remove CGI support
      def dispatch(cgi = nil, session_options = CgiRequest::DEFAULT_SESSION_OPTIONS, output = $stdout)
        new(output).dispatch_cgi(cgi, session_options)
      end
 
      # Add a preparation callback. Preparation callbacks are run before every
      # request in development mode, and before the first request in production
      # mode.
      #
      # An optional identifier may be supplied for the callback. If provided,
      # to_prepare may be called again with the same identifier to replace the
      # existing callback. Passing an identifier is a suggested practice if the
      # code adding a preparation block may be reloaded.
      def to_prepare(identifier = nil, &block)
        @prepare_dispatch_callbacks ||= ActiveSupport::Callbacks::CallbackChain.new
        callback = ActiveSupport::Callbacks::Callback.new(:prepare_dispatch, block, :identifier => identifier)
        @prepare_dispatch_callbacks.replace_or_append!(callback)
      end
    end
 
    cattr_accessor :middleware
    self.middleware = MiddlewareStack.new do |middleware|
      middlewares = File.join(File.dirname(__FILE__), "middlewares.rb")
      middleware.instance_eval(File.read(middlewares))
    end
 
    include ActiveSupport::Callbacks
    define_callbacks :prepare_dispatch, :before_dispatch, :after_dispatch
 
    # DEPRECATE: Remove arguments, since they are only used by CGI
    def initialize(output = $stdout, request = nil, response = nil)
      @output = output
      @app = @@middleware.build(lambda { |env| self.dup._call(env) })
    end
 
    def dispatch
      begin
        run_callbacks :before_dispatch
        Routing::Routes.call(@env)
      rescue Exception => exception
        if controller ||= (::ApplicationController rescue Base)
          controller.call_with_exception(@env, exception).to_a
        else
          raise exception
        end
      ensure
        run_callbacks :after_dispatch, :enumerator => :reverse_each
      end
    end
 
    # DEPRECATE: Remove CGI support
    def dispatch_cgi(cgi, session_options)
      CGIHandler.dispatch_cgi(self, cgi, @output)
    end
 
    def call(env)
      @app.call(env)
    end
 
    def _call(env)
      @env = env
      dispatch
    end
 
    def reload_application
      # Run prepare callbacks before every request in development mode
      run_callbacks :prepare_dispatch
 
      Routing::Routes.reload
    end
 
    # Cleanup the application by clearing out loaded classes so they can
    # be reloaded on the next request without restarting the server.
    def cleanup_application
      ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
      ActiveSupport::Dependencies.clear
      ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord)
    end
 
    def flush_logger
      Base.logger.flush
    end
 
    def checkin_connections
      # Don't return connection (and peform implicit rollback) if this request is a part of integration test
      return if @env.key?("rack.test")
      ActiveRecord::Base.clear_active_connections!
    end
  end
end
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server