问题
I am newbie to Rack and Rails metal, can anyone tell me which situation has to use which?. According to my understanding both Rack and Metal to filter/bypass http request and response. Need a better clarification, when to use what? Thanks in advance!!!
回答1:
As far as I know Rails Metal has been removed from Rails 3 a long time ago. Basically it used to be a thin wrapper around Rack that could act more like an endpoint rather than a filter (which is usually the case with Rack middleware). Check this post for a more detailed explanation: http://jnewland.github.io/articles/2008/12/16/rails-metal-a-micro-framework-with-the-power-of-rails-m/
Nowadays, as an alternative, what you can use is ActionController::Metal which is a very lightweight controller that can provide very fast responses without offering many of the "cool" Rails stuff.
As far as Rack is concerned it is basically:
a minimal interface between webservers supporting Ruby and Ruby frameworks.
So it basically helps standardize the communication between any webserver that supports Ruby with any possible Ruby web framework.
Here is a nice schematic representation of what Rack does taken from Passenger's docs

来源:https://stackoverflow.com/questions/21603658/what-is-the-exact-difference-between-rack-and-rails-metal-in-ruby-on-rails