Browse files

Rails on Rack Rails guide: indicate that Metal pieces now require an …

…"X-Cascade" header with a value of "pass" to continue the Metal chain execution instead of a HTTP 404 response. Also removed reference to old code.
  • Loading branch information...
1 parent 15efaa7 commit ad4615e97896428ca140411081442f1b5e7d6089 @chuyeow chuyeow committed with fxn Apr 19, 2010
Showing with 5 additions and 17 deletions.
  1. +5 −17 railties/guides/source/rails_on_rack.textile
@@ -247,7 +247,7 @@ class Poller
if env["PATH_INFO"] =~ /^\/poller/
[200, {"Content-Type" => "text/html"}, ["Hello, World!"]]
- [404, {"Content-Type" => "text/html"}, ["Not Found"]]
+ [404, {"Content-Type" => "text/html", "X-Cascade" => "pass"}, ["Not Found"]]
@@ -257,23 +257,13 @@ Metal applications within +app/metal+ folders in plugins will also be discovered
Metal applications are an optimization. You should make sure to "understand the related performance implications": before using it.
-h4. Execution Order
-All Metal Applications are executed by +Rails::Rack::Metal+ middleware, which is a part of the +ActionController::MiddlewareStack+ chain.
+WARNING: To continue the Metal chain execution, return an +X-Cascade+ HTTP header with a value of +pass+.
-Here's the primary method responsible for running the Metal applications:
+h4. Execution Order
-def call(env)
- @metals.keys.each do |app|
- result =
- return result unless result[0].to_i == 404
- end
+All Metal Applications are executed in alphabetical order of their filenames, so +aaa.rb+ will come before +bbb.rb+ in the metal chain.
-In the code above, +@metals+ is an ordered hash of metal applications. Due to the default alphabetical ordering, +aaa.rb+ will come before +bbb.rb+ in the metal chain.
+You can override the default ordering in your environment. Simply add a line like the following to +config/application.rb+
It is, however, possible to override the default ordering in your environment. Simply add a line like the following to +config/environment.rb+
@@ -283,8 +273,6 @@ config.metals = ["Bbb", "Aaa"]
Each string in the array should be the name of your metal class. If you do this then be warned that any metal applications not listed will not be loaded.
-WARNING: Metal applications cannot return the HTTP Status +404+ to a client, as it is used for continuing the Metal chain execution. Please use normal Rails controllers or a custom middleware if returning +404+ is a requirement.
h3. Resources
h4. Learning Rack

0 comments on commit ad4615e

Please sign in to comment.