Get Your Rails Metal in Order

by woody2shoes on May 14, 2009

I’ve been playing with Rails Metal for quite some time now. Under certain circumstances, one Metal would catch something I intended for another metal deeper in the middleware stack. Reordering became the order of the day. The only problem was that the Rails Guide was in the works and I didn’t want to hack my metal files to put them in alphabetical order to match the order I wanted them in.

So, without further ado, here is how you reorder your Rails Metal middleware stack:

Open you environment.rb file:

vi config/environment.rb

Then add this line inside the initialization block:

config.metals = ["FirstMetal", "ThirdMetal", "SecondMetal", "FinalMetal"]

The strings in the array are the names of the metal files in camel case.

Previous post:

Next post: