railties 3.0.20 → 3.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. data/CHANGELOG +36 -49
  2. data/README.rdoc +2 -1
  3. data/guides/assets/stylesheets/fixes.css +16 -0
  4. data/guides/rails_guides.rb +2 -2
  5. data/guides/rails_guides/generator.rb +8 -3
  6. data/guides/rails_guides/textile_extensions.rb +4 -2
  7. data/guides/source/2_2_release_notes.textile +3 -3
  8. data/guides/source/2_3_release_notes.textile +2 -2
  9. data/guides/source/3_0_release_notes.textile +14 -14
  10. data/guides/source/action_controller_overview.textile +54 -79
  11. data/guides/source/action_mailer_basics.textile +39 -9
  12. data/guides/source/action_view_overview.textile +257 -211
  13. data/guides/source/active_record_basics.textile +1 -1
  14. data/guides/source/active_record_querying.textile +217 -27
  15. data/guides/source/active_record_validations_callbacks.textile +94 -25
  16. data/guides/source/active_support_core_extensions.textile +109 -77
  17. data/guides/source/ajax_on_rails.textile +15 -150
  18. data/guides/source/api_documentation_guidelines.textile +12 -12
  19. data/guides/source/association_basics.textile +74 -60
  20. data/guides/source/caching_with_rails.textile +59 -60
  21. data/guides/source/command_line.textile +46 -47
  22. data/guides/source/configuring.textile +55 -37
  23. data/guides/source/contribute.textile +7 -7
  24. data/guides/source/contributing_to_ruby_on_rails.textile +14 -23
  25. data/guides/source/credits.html.erb +3 -3
  26. data/guides/source/debugging_rails_applications.textile +59 -46
  27. data/guides/source/form_helpers.textile +76 -31
  28. data/guides/source/generators.textile +39 -40
  29. data/guides/source/getting_started.textile +73 -94
  30. data/guides/source/i18n.textile +64 -58
  31. data/guides/source/index.html.erb +3 -3
  32. data/guides/source/initialization.textile +634 -3284
  33. data/guides/source/layout.html.erb +6 -7
  34. data/guides/source/layouts_and_rendering.textile +59 -60
  35. data/guides/source/migrations.textile +63 -59
  36. data/guides/source/nested_model_forms.textile +2 -2
  37. data/guides/source/performance_testing.textile +16 -16
  38. data/guides/source/plugins.textile +236 -1280
  39. data/guides/source/rails_application_templates.textile +37 -29
  40. data/guides/source/rails_on_rack.textile +4 -9
  41. data/guides/source/routing.textile +96 -75
  42. data/guides/source/ruby_on_rails_guides_guidelines.textile +19 -12
  43. data/guides/source/security.textile +57 -30
  44. data/guides/source/testing.textile +26 -24
  45. data/guides/w3c_validator.rb +2 -2
  46. data/lib/rails.rb +1 -7
  47. data/lib/rails/application.rb +46 -76
  48. data/lib/rails/application/bootstrap.rb +6 -11
  49. data/lib/rails/application/configuration.rb +43 -40
  50. data/lib/rails/application/finisher.rb +16 -4
  51. data/lib/rails/application/railties.rb +6 -24
  52. data/lib/rails/application/routes_reloader.rb +45 -0
  53. data/lib/rails/backtrace_cleaner.rb +1 -1
  54. data/lib/rails/cli.rb +7 -5
  55. data/lib/rails/commands.rb +27 -2
  56. data/lib/rails/commands/application.rb +14 -1
  57. data/lib/rails/commands/benchmarker.rb +3 -1
  58. data/lib/rails/commands/dbconsole.rb +2 -2
  59. data/lib/rails/commands/destroy.rb +3 -1
  60. data/lib/rails/commands/generate.rb +3 -1
  61. data/lib/rails/commands/plugin.rb +2 -7
  62. data/lib/rails/commands/plugin_new.rb +10 -0
  63. data/lib/rails/commands/profiler.rb +3 -1
  64. data/lib/rails/commands/server.rb +4 -0
  65. data/lib/rails/configuration.rb +8 -81
  66. data/lib/rails/console/app.rb +2 -2
  67. data/lib/rails/engine.rb +460 -78
  68. data/lib/rails/engine/configuration.rb +46 -49
  69. data/lib/rails/engine/railties.rb +33 -0
  70. data/lib/rails/generators.rb +11 -5
  71. data/lib/rails/generators/actions.rb +2 -27
  72. data/lib/rails/generators/app_base.rb +216 -0
  73. data/lib/rails/generators/base.rb +3 -2
  74. data/lib/rails/generators/erb/scaffold/templates/index.html.erb +1 -1
  75. data/lib/rails/generators/generated_attribute.rb +2 -1
  76. data/lib/rails/generators/migration.rb +6 -2
  77. data/lib/rails/generators/named_base.rb +79 -3
  78. data/lib/rails/generators/rails/app/app_generator.rb +44 -209
  79. data/lib/rails/generators/rails/app/templates/Gemfile +15 -31
  80. data/lib/rails/generators/rails/app/templates/README +2 -2
  81. data/lib/rails/generators/rails/app/templates/Rakefile +1 -1
  82. data/lib/rails/generators/rails/app/templates/{public → app/assets}/images/rails.png +0 -0
  83. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +8 -0
  84. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +5 -0
  85. data/lib/rails/generators/rails/app/templates/app/mailers/.empty_directory +0 -0
  86. data/lib/rails/generators/rails/app/templates/app/models/.empty_directory +0 -0
  87. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -4
  88. data/lib/rails/generators/rails/app/templates/config/application.rb +19 -3
  89. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +4 -4
  90. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +11 -6
  91. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +3 -3
  92. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +1 -1
  93. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +1 -2
  94. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +14 -11
  95. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +5 -1
  96. data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -1
  97. data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +12 -0
  98. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +1 -1
  99. data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
  100. data/lib/rails/generators/rails/app/templates/db/{seeds.rb → seeds.rb.tt} +2 -2
  101. data/lib/rails/generators/rails/app/templates/public/index.html +10 -8
  102. data/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
  103. data/lib/rails/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
  104. data/lib/rails/generators/rails/app/templates/test/functional/.empty_directory +0 -0
  105. data/lib/rails/generators/rails/app/templates/test/integration/.empty_directory +0 -0
  106. data/lib/rails/generators/rails/app/templates/test/{test_helper.rb.tt → test_helper.rb} +0 -0
  107. data/lib/rails/generators/rails/app/templates/test/unit/.empty_directory +0 -0
  108. data/lib/rails/generators/rails/assets/USAGE +20 -0
  109. data/lib/rails/generators/rails/assets/assets_generator.rb +39 -0
  110. data/lib/rails/generators/rails/assets/templates/javascript.js +2 -0
  111. data/lib/rails/generators/rails/assets/templates/javascript.js.coffee +3 -0
  112. data/lib/rails/generators/rails/assets/templates/stylesheet.css +4 -0
  113. data/lib/rails/generators/rails/assets/templates/stylesheet.css.scss +5 -0
  114. data/lib/rails/generators/rails/controller/controller_generator.rb +1 -1
  115. data/lib/rails/generators/rails/controller/templates/controller.rb +2 -0
  116. data/lib/rails/generators/rails/generator/generator_generator.rb +2 -2
  117. data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
  118. data/lib/rails/generators/rails/helper/templates/helper.rb +2 -0
  119. data/lib/rails/generators/rails/plugin/plugin_generator.rb +7 -0
  120. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -4
  121. data/lib/rails/generators/rails/plugin_new/USAGE +10 -0
  122. data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +303 -0
  123. data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +9 -0
  124. data/lib/rails/generators/rails/plugin_new/templates/Gemfile +11 -0
  125. data/lib/rails/generators/rails/plugin_new/templates/MIT-LICENSE +20 -0
  126. data/lib/rails/generators/rails/plugin_new/templates/README.rdoc +3 -0
  127. data/lib/rails/generators/rails/plugin_new/templates/Rakefile +21 -0
  128. data/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt +4 -0
  129. data/lib/rails/generators/rails/plugin_new/templates/app/helpers/%name%/application_helper.rb.tt +4 -0
  130. data/lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory +0 -0
  131. data/lib/rails/generators/rails/plugin_new/templates/config/routes.rb +6 -0
  132. data/lib/rails/generators/rails/plugin_new/templates/gitignore +6 -0
  133. data/lib/rails/generators/rails/plugin_new/templates/lib/%name%.rb +6 -0
  134. data/lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb +7 -0
  135. data/lib/rails/generators/rails/plugin_new/templates/lib/tasks/%name%_tasks.rake +4 -0
  136. data/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +16 -0
  137. data/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb +10 -0
  138. data/lib/rails/generators/rails/plugin_new/templates/rails/routes.rb +4 -0
  139. data/lib/rails/generators/rails/plugin_new/templates/script/rails.tt +5 -0
  140. data/lib/rails/generators/rails/plugin_new/templates/test/%name%_test.rb +7 -0
  141. data/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb +12 -0
  142. data/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb +10 -0
  143. data/lib/rails/generators/rails/resource/resource_generator.rb +2 -2
  144. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +20 -1
  145. data/lib/rails/generators/rails/{stylesheets → scaffold}/templates/scaffold.css +0 -0
  146. data/lib/rails/generators/rails/scaffold/templates/scaffold.css.scss +58 -0
  147. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +21 -19
  148. data/lib/rails/generators/resource_helpers.rb +3 -3
  149. data/lib/rails/generators/test_case.rb +2 -20
  150. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +5 -4
  151. data/lib/rails/generators/test_unit/helper/templates/helper_test.rb +2 -0
  152. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb +3 -4
  153. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +5 -4
  154. data/lib/rails/generators/test_unit/model/templates/fixtures.yml +1 -1
  155. data/lib/rails/generators/test_unit/model/templates/unit_test.rb +5 -4
  156. data/lib/rails/generators/test_unit/observer/templates/unit_test.rb +5 -4
  157. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +3 -4
  158. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +7 -5
  159. data/lib/rails/info.rb +0 -1
  160. data/lib/rails/paths.rb +119 -65
  161. data/lib/rails/plugin.rb +18 -19
  162. data/lib/rails/rack/log_tailer.rb +1 -1
  163. data/lib/rails/railtie.rb +50 -47
  164. data/lib/rails/railtie/configurable.rb +20 -10
  165. data/lib/rails/railtie/configuration.rb +20 -19
  166. data/lib/rails/source_annotation_extractor.rb +5 -5
  167. data/lib/rails/tasks.rb +1 -0
  168. data/lib/rails/tasks/assets.rake +10 -0
  169. data/lib/rails/tasks/documentation.rake +2 -8
  170. data/lib/rails/tasks/engine.rake +69 -0
  171. data/lib/rails/tasks/framework.rake +4 -21
  172. data/lib/rails/tasks/misc.rake +1 -1
  173. data/lib/rails/tasks/routes.rake +2 -1
  174. data/lib/rails/test_help.rb +17 -1
  175. data/lib/rails/test_unit/railtie.rb +1 -1
  176. data/lib/rails/test_unit/testing.rake +8 -3
  177. data/lib/rails/version.rb +3 -3
  178. metadata +128 -100
  179. checksums.yaml +0 -7
  180. data/lib/rails/application/configurable.rb +0 -19
  181. data/lib/rails/console/sandbox.rb +0 -6
  182. data/lib/rails/deprecation.rb +0 -41
  183. data/lib/rails/engine/configurable.rb +0 -25
  184. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +0 -62
  185. data/lib/rails/generators/rails/app/templates/public/javascripts/application.js +0 -2
  186. data/lib/rails/generators/rails/app/templates/public/javascripts/controls.js +0 -965
  187. data/lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js +0 -974
  188. data/lib/rails/generators/rails/app/templates/public/javascripts/effects.js +0 -1123
  189. data/lib/rails/generators/rails/app/templates/public/javascripts/prototype.js +0 -6001
  190. data/lib/rails/generators/rails/app/templates/public/javascripts/rails.js +0 -202
  191. data/lib/rails/generators/rails/stylesheets/USAGE +0 -5
  192. data/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb +0 -9
  193. data/lib/rails/info_routes.rb +0 -3
@@ -8,7 +8,6 @@ require 'active_support/core_ext/logger'
8
8
 
9
9
  require 'rails/application'
10
10
  require 'rails/version'
11
- require 'rails/deprecation'
12
11
 
13
12
  require 'active_support/railtie'
14
13
  require 'action_dispatch/railtie'
@@ -93,12 +92,7 @@ module Rails
93
92
  end
94
93
 
95
94
  def public_path
96
- application && application.paths.public.to_a.first
97
- end
98
-
99
- def public_path=(path)
100
- ActiveSupport::Deprecation.warn "Setting Rails.public_path= is deprecated. " <<
101
- "Please set paths.public = in config/application.rb instead.", caller
95
+ application && application.paths["public"].first
102
96
  end
103
97
  end
104
98
  end
@@ -35,30 +35,12 @@ module Rails
35
35
  #
36
36
  class Application < Engine
37
37
  autoload :Bootstrap, 'rails/application/bootstrap'
38
- autoload :Configurable, 'rails/application/configurable'
39
38
  autoload :Configuration, 'rails/application/configuration'
40
39
  autoload :Finisher, 'rails/application/finisher'
41
40
  autoload :Railties, 'rails/application/railties'
41
+ autoload :RoutesReloader, 'rails/application/routes_reloader'
42
42
 
43
43
  class << self
44
- private :new
45
-
46
- def configure(&block)
47
- class_eval(&block)
48
- end
49
-
50
- def instance
51
- if self == Rails::Application
52
- if Rails.application
53
- ActiveSupport::Deprecation.warn "Calling a method in Rails::Application is deprecated, " <<
54
- "please call it directly in your application constant #{Rails.application.class.name}.", caller
55
- end
56
- Rails.application
57
- else
58
- @@instance ||= new
59
- end
60
- end
61
-
62
44
  def inherited(base)
63
45
  raise "You cannot have more than one Rails::Application" if Rails.application
64
46
  super
@@ -66,19 +48,10 @@ module Rails
66
48
  Rails.application.add_lib_to_load_path!
67
49
  ActiveSupport.run_load_hooks(:before_configuration, base.instance)
68
50
  end
69
-
70
- def respond_to?(*args)
71
- super || instance.respond_to?(*args)
72
- end
73
-
74
- protected
75
-
76
- def method_missing(*args, &block)
77
- instance.send(*args, &block)
78
- end
79
51
  end
80
52
 
81
- delegate :middleware, :to => :config
53
+ attr_accessor :assets
54
+ delegate :default_url_options, :default_url_options=, :to => :routes
82
55
 
83
56
  # This method is called just after an application inherits from Rails::Application,
84
57
  # allowing the developer to load classes in lib and use them during application
@@ -99,7 +72,7 @@ module Rails
99
72
  end
100
73
 
101
74
  def require_environment! #:nodoc:
102
- environment = paths.config.environment.to_a.first
75
+ environment = paths["config/environment"].existent.first
103
76
  require environment if environment
104
77
  end
105
78
 
@@ -108,30 +81,18 @@ module Rails
108
81
  super
109
82
  end
110
83
 
111
- def routes
112
- @routes ||= ActionDispatch::Routing::RouteSet.new
113
- end
114
-
115
- def railties
116
- @railties ||= Railties.new(config)
84
+ def reload_routes!
85
+ routes_reloader.reload!
117
86
  end
118
87
 
119
88
  def routes_reloader
120
- @routes_reloader ||= ActiveSupport::FileUpdateChecker.new([]){ reload_routes! }
121
- end
122
-
123
- def reload_routes!
124
- _routes = self.routes
125
- _routes.disable_clear_and_finalize = true
126
- _routes.clear!
127
- routes_reloader.paths.each { |path| load(path) }
128
- ActiveSupport.on_load(:action_controller) { _routes.finalize! }
129
- ensure
130
- _routes.disable_clear_and_finalize = false
89
+ @routes_reloader ||= RoutesReloader.new
131
90
  end
132
91
 
133
92
  def initialize!
93
+ raise "Application has been already initialized." if @initialized
134
94
  run_initializers(self)
95
+ @initialized = true
135
96
  self
136
97
  end
137
98
 
@@ -151,51 +112,57 @@ module Rails
151
112
 
152
113
  def load_console(sandbox=false)
153
114
  initialize_console(sandbox)
154
- railties.all { |r| r.load_console }
115
+ railties.all { |r| r.load_console(sandbox) }
155
116
  super()
156
117
  self
157
118
  end
158
119
 
159
- def app
160
- @app ||= begin
161
- config.middleware = config.middleware.merge_into(default_middleware_stack)
162
- config.middleware.build(routes)
163
- end
164
- end
165
- alias :build_middleware_stack :app
166
-
167
- def call(env)
168
- app.call(env.reverse_merge!(env_defaults))
169
- end
170
-
171
- def env_defaults
172
- @env_defaults ||= {
120
+ def env_config
121
+ @env_config ||= super.merge({
173
122
  "action_dispatch.parameter_filter" => config.filter_parameters,
174
123
  "action_dispatch.secret_token" => config.secret_token,
175
124
  "action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions
176
- }
125
+ })
177
126
  end
178
127
 
179
128
  def initializers
180
- initializers = Bootstrap.initializers_for(self)
181
- railties.all { |r| initializers += r.initializers }
182
- initializers += super
183
- initializers += Finisher.initializers_for(self)
184
- initializers
129
+ Bootstrap.initializers_for(self) +
130
+ super +
131
+ Finisher.initializers_for(self)
132
+ end
133
+
134
+ def config
135
+ @config ||= Application::Configuration.new(find_root_with_flag("config.ru", Dir.pwd))
185
136
  end
186
137
 
187
138
  protected
188
139
 
140
+ alias :build_middleware_stack :app
141
+
189
142
  def default_middleware_stack
190
143
  ActionDispatch::MiddlewareStack.new.tap do |middleware|
191
- middleware.use ::ActionDispatch::Static, paths.public.to_a.first if config.serve_static_assets
192
- middleware.use ::Rack::Lock if !config.allow_concurrency
144
+ if rack_cache = config.action_controller.perform_caching && config.action_dispatch.rack_cache
145
+ require "action_dispatch/http/rack_cache"
146
+ middleware.use ::Rack::Cache, rack_cache
147
+ end
148
+
149
+ if config.force_ssl
150
+ require "rack/ssl"
151
+ middleware.use ::Rack::SSL
152
+ end
153
+
154
+ if config.serve_static_assets
155
+ middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control
156
+ end
157
+
158
+ middleware.use ::Rack::Lock unless config.allow_concurrency
193
159
  middleware.use ::Rack::Runtime
194
160
  middleware.use ::Rails::Rack::Logger
195
161
  middleware.use ::ActionDispatch::ShowExceptions, config.consider_all_requests_local
196
162
  middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies
197
163
  middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header
198
- middleware.use ::ActionDispatch::Callbacks, !config.cache_classes
164
+ middleware.use ::ActionDispatch::Reloader unless config.cache_classes
165
+ middleware.use ::ActionDispatch::Callbacks
199
166
  middleware.use ::ActionDispatch::Cookies
200
167
 
201
168
  if config.session_store
@@ -206,12 +173,16 @@ module Rails
206
173
  middleware.use ::ActionDispatch::ParamsParser
207
174
  middleware.use ::Rack::MethodOverride
208
175
  middleware.use ::ActionDispatch::Head
209
- middleware.use ::ActionDispatch::BestStandardsSupport, config.action_dispatch.best_standards_support if config.action_dispatch.best_standards_support
176
+ middleware.use ::Rack::ConditionalGet
177
+ middleware.use ::Rack::ETag, "no-cache"
178
+
179
+ if config.action_dispatch.best_standards_support
180
+ middleware.use ::ActionDispatch::BestStandardsSupport, config.action_dispatch.best_standards_support
181
+ end
210
182
  end
211
183
  end
212
184
 
213
185
  def initialize_tasks
214
- extend Rake::DSL if defined? Rake::DSL
215
186
  require "rails/tasks"
216
187
  task :environment do
217
188
  $rails_rake_task = true
@@ -225,8 +196,7 @@ module Rails
225
196
 
226
197
  def initialize_console(sandbox=false)
227
198
  require "rails/console/app"
228
- require "rails/console/sandbox" if sandbox
229
199
  require "rails/console/helpers"
230
200
  end
231
201
  end
232
- end
202
+ end
@@ -6,10 +6,7 @@ module Rails
6
6
  module Bootstrap
7
7
  include Initializable
8
8
 
9
- initializer :load_environment_config do
10
- environment = config.paths.config.environments.to_a.first
11
- require environment if environment
12
- end
9
+ initializer :load_environment_hook do end
13
10
 
14
11
  initializer :load_active_support do
15
12
  require 'active_support/dependencies'
@@ -26,7 +23,7 @@ module Rails
26
23
  # Initialize the logger early in the stack in case we need to log some deprecation.
27
24
  initializer :initialize_logger do
28
25
  Rails.logger ||= config.logger || begin
29
- path = config.paths.log.to_a.first
26
+ path = config.paths["log"].first
30
27
  logger = ActiveSupport::BufferedLogger.new(path)
31
28
  logger.level = ActiveSupport::BufferedLogger.const_get(config.log_level.to_s.upcase)
32
29
  logger.auto_flushing = false if Rails.env.production?
@@ -54,11 +51,9 @@ module Rails
54
51
  end
55
52
 
56
53
  initializer :set_clear_dependencies_hook do
57
- unless config.cache_classes
58
- ActionDispatch::Callbacks.after do
59
- ActiveSupport::DescendantsTracker.clear
60
- ActiveSupport::Dependencies.clear
61
- end
54
+ ActionDispatch::Reloader.to_cleanup do
55
+ ActiveSupport::DescendantsTracker.clear
56
+ ActiveSupport::Dependencies.clear
62
57
  end
63
58
  end
64
59
 
@@ -73,4 +68,4 @@ module Rails
73
68
  end
74
69
  end
75
70
  end
76
- end
71
+ end
@@ -1,33 +1,48 @@
1
- require 'active_support/deprecation'
2
1
  require 'active_support/core_ext/string/encoding'
3
2
  require 'rails/engine/configuration'
4
3
 
5
4
  module Rails
6
5
  class Application
7
6
  class Configuration < ::Rails::Engine::Configuration
8
- include ::Rails::Configuration::Deprecated
7
+ attr_accessor :allow_concurrency, :asset_host, :asset_path, :assets,
8
+ :cache_classes, :cache_store, :consider_all_requests_local,
9
+ :dependency_loading, :encoding, :filter_parameters,
10
+ :force_ssl, :helpers_paths, :logger, :preload_frameworks,
11
+ :reload_plugins, :secret_token, :serve_static_assets,
12
+ :static_cache_control, :session_options, :time_zone, :whiny_nils
9
13
 
10
- attr_accessor :allow_concurrency, :cache_classes, :cache_store,
11
- :encoding, :consider_all_requests_local, :dependency_loading,
12
- :filter_parameters, :log_level, :logger, :middleware,
13
- :plugins, :preload_frameworks, :reload_plugins,
14
- :secret_token, :serve_static_assets, :session_options,
15
- :time_zone, :whiny_nils
16
-
17
- alias :generators :app_generators
14
+ attr_writer :log_level
18
15
 
19
16
  def initialize(*)
20
17
  super
21
18
  self.encoding = "utf-8"
22
- @allow_concurrency = false
19
+ @allow_concurrency = false
23
20
  @consider_all_requests_local = false
24
- @filter_parameters = []
25
- @dependency_loading = true
26
- @serve_static_assets = true
27
- @session_store = :cookie_store
28
- @session_options = {}
29
- @time_zone = "UTC"
30
- @middleware = app_middleware
21
+ @filter_parameters = []
22
+ @helpers_paths = []
23
+ @dependency_loading = true
24
+ @serve_static_assets = true
25
+ @static_cache_control = nil
26
+ @force_ssl = false
27
+ @session_store = :cookie_store
28
+ @session_options = {}
29
+ @time_zone = "UTC"
30
+ @log_level = nil
31
+ @middleware = app_middleware
32
+ @generators = app_generators
33
+
34
+ @assets = ActiveSupport::OrderedOptions.new
35
+ @assets.enabled = false
36
+ @assets.paths = []
37
+ @assets.precompile = [ /\w+\.(?!js|css)$/, "application.js", "application.css" ]
38
+ @assets.prefix = "/assets"
39
+
40
+ @assets.js_compressor = nil
41
+ @assets.css_compressor = nil
42
+ end
43
+
44
+ def compiled_asset_path
45
+ "/"
31
46
  end
32
47
 
33
48
  def encoding=(value)
@@ -47,23 +62,15 @@ module Rails
47
62
  def paths
48
63
  @paths ||= begin
49
64
  paths = super
50
- paths.app.controllers << builtin_controller if builtin_controller
51
- paths.config.database "config/database.yml"
52
- paths.config.environment "config/environment.rb"
53
- paths.config.environments "config/environments", :glob => "#{Rails.env}.rb"
54
- paths.lib.templates "lib/templates"
55
- paths.log "log/#{Rails.env}.log"
56
- paths.tmp "tmp"
57
- paths.tmp.cache "tmp/cache"
58
- paths.vendor "vendor", :load_path => true
59
- paths.vendor.plugins "vendor/plugins"
60
-
61
- if File.exists?("#{root}/test/mocks/#{Rails.env}")
62
- ActiveSupport::Deprecation.warn "\"Rails.root/test/mocks/#{Rails.env}\" won't be added " <<
63
- "automatically to load paths anymore in future releases"
64
- paths.mocks_path "test/mocks", :autoload => true, :glob => Rails.env
65
- end
66
-
65
+ paths.add "config/database", :with => "config/database.yml"
66
+ paths.add "config/environment", :with => "config/environment.rb"
67
+ paths.add "lib/templates"
68
+ paths.add "log", :with => "log/#{Rails.env}.log"
69
+ paths.add "public"
70
+ paths.add "public/javascripts"
71
+ paths.add "public/stylesheets"
72
+ paths.add "tmp"
73
+ paths.add "tmp/cache"
67
74
  paths
68
75
  end
69
76
  end
@@ -85,7 +92,7 @@ module Rails
85
92
  # YAML::load.
86
93
  def database_configuration
87
94
  require 'erb'
88
- YAML::load(ERB.new(IO.read(paths.config.database.to_a.first)).result)
95
+ YAML::load(ERB.new(IO.read(paths["config/database"].first)).result)
89
96
  end
90
97
 
91
98
  def cache_store
@@ -98,10 +105,6 @@ module Rails
98
105
  end
99
106
  end
100
107
 
101
- def builtin_controller
102
- File.expand_path('../info_routes', __FILE__) if Rails.env.development?
103
- end
104
-
105
108
  def log_level
106
109
  @log_level ||= Rails.env.production? ? :info : :debug
107
110
  end
@@ -4,7 +4,7 @@ module Rails
4
4
  include Initializable
5
5
 
6
6
  initializer :add_generator_templates do
7
- config.generators.templates.unshift(*paths.lib.templates.to_a)
7
+ config.generators.templates.unshift(*paths["lib/templates"].existent)
8
8
  end
9
9
 
10
10
  initializer :ensure_autoload_once_paths_as_subset do
@@ -21,13 +21,15 @@ module Rails
21
21
 
22
22
  initializer :add_to_prepare_blocks do
23
23
  config.to_prepare_blocks.each do |block|
24
- ActionDispatch::Callbacks.to_prepare(&block)
24
+ ActionDispatch::Reloader.to_prepare(&block)
25
25
  end
26
26
  end
27
27
 
28
28
  initializer :add_builtin_route do |app|
29
29
  if Rails.env.development?
30
- app.routes_reloader.paths << File.expand_path('../../info_routes.rb', __FILE__)
30
+ app.routes.append do
31
+ match '/rails/info/properties' => "rails/info#properties"
32
+ end
31
33
  end
32
34
  end
33
35
 
@@ -35,6 +37,14 @@ module Rails
35
37
  build_middleware_stack
36
38
  end
37
39
 
40
+ initializer :run_prepare_callbacks do
41
+ ActionDispatch::Reloader.prepare!
42
+ end
43
+
44
+ initializer :define_main_app_helper do |app|
45
+ app.routes.define_mounted_helper(:main_app)
46
+ end
47
+
38
48
  initializer :eager_load! do
39
49
  if config.cache_classes && !$rails_rake_task
40
50
  ActiveSupport.run_load_hooks(:before_eager_load, self)
@@ -47,10 +57,12 @@ module Rails
47
57
  end
48
58
 
49
59
  # Force routes to be loaded just at the end and add it to to_prepare callbacks
60
+ # This needs to be after the finisher hook to ensure routes added in the hook
61
+ # are still loaded.
50
62
  initializer :set_routes_reloader do |app|
51
63
  reloader = lambda { app.routes_reloader.execute_if_updated }
52
64
  reloader.call
53
- ActionDispatch::Callbacks.to_prepare(&reloader)
65
+ ActionDispatch::Reloader.to_prepare(&reloader)
54
66
  end
55
67
 
56
68
  # Disable dependency loading during request cycle
@@ -1,31 +1,13 @@
1
- module Rails
2
- class Application
3
- class Railties
4
- # TODO Write tests for this behavior extracted from Application
5
- def initialize(config)
6
- @config = config
7
- end
1
+ require 'rails/engine/railties'
8
2
 
3
+ module Rails
4
+ class Application < Engine
5
+ class Railties < Rails::Engine::Railties
9
6
  def all(&block)
10
- @all ||= railties + engines + plugins
7
+ @all ||= railties + engines + super
11
8
  @all.each(&block) if block
12
9
  @all
13
10
  end
14
-
15
- def railties
16
- @railties ||= ::Rails::Railtie.subclasses.map(&:new)
17
- end
18
-
19
- def engines
20
- @engines ||= ::Rails::Engine.subclasses.map(&:new)
21
- end
22
-
23
- def plugins
24
- @plugins ||= begin
25
- plugin_names = (@config.plugins || [:all]).map { |p| p.to_sym }
26
- Plugin.all(plugin_names, @config.paths.vendor.plugins)
27
- end
28
- end
29
11
  end
30
12
  end
31
- end
13
+ end