permalink

Rails 3 + Metal

There has been a lot of talk about the new changes being introduced into rails 3, trying to upgrade current applications I found out a recipe for upgrading your Metal code:

The first thing is to change

require(File.dirname(__FILE__) + ”/../../config/environment”) unless defined?(Rails)

into

require File.expand_path(’../../../config/environment’, __FILE__) unless defined?(Rails)

This way using the new system for the absolute path to your app.

Next depending on the function of your app you should change

[404, {“Content-Type” => “text/html”}, [“Not Found”]]

in to

[404, {“Content-Type” => “text/html”, “X-Cascade” => “pass”}, [“Not Found”]]

ThisĀ ”X-Cascade” => “pass” allows for the call to keep going through your routes and see if any other catches this call.

Last is to declare your action on the router, this wasn’t necessary on Rails 2 since Metal would go through Rack before Rails, but now that Rails is an actual Rack app, we need to express all of our routes.

match ‘/metal_path’, :to => MetalClass

blog comments powered by Disqus