class Accelerator
def self.call(env)
if env[“PATH_INFO”] =~ /^/accelerator/
[200, {“Content-Type” => “text/html”}, [“Hello, World!”]]
else
[404, {“Content-Type” => “text/html”}, [“Not Found”]]
end
end
end
--------------code-end------------------
with the code i can process every request without configure rails
router. how can i do the same thing in rails3?
end
end
end
--------------code-end------------------
with the code i can process every request without configure rails
router. how can i do the same thing in rails3?
Quon, the cool thing about Rails 3 is that the router can accept any
Rack
application. Thus, one can do the above in Rails 3 as follows:
routes.rb:
root :to => Accelerator
match ‘:controller(/:action(/:id(.:format)))’ => Accelerator
class Accelerator
def self.call(env)
if env[“PATH_INFO”] =~ /^/accelerator/
[200, {“Content-Type” => “text/html”}, [“Hello, World!”]]
else
[404, {“Content-Type” => “text/html”}, [“Not Found”]]
end
end
end
This is one way to do it but I’m sure it’s a Rails 3 way to DRY up the
routes.