Skip to content

Instantly share code, notes, and snippets.

@knzai
Created April 21, 2010 17:32
Show Gist options
  • Save knzai/374139 to your computer and use it in GitHub Desktop.
Save knzai/374139 to your computer and use it in GitHub Desktop.
use Rack::Bug
map '/my_sweet_rack_app'
run MySweetRackApp.new
end
map '/'
DenyAccessAndRecordRetinaApp.new
end
def app
eval "Rack::Builder.new {( " + File.read(File.dirname(__FILE__) + '/../config.ru') + "\n )}"
end
@knaveofdiamonds
Copy link

Instead of Using File.dirname, it is better to change into the directory where config.ru, otherwise if you used File.dirname in the rackup file, it will get the load paths confused:

Dir.chdir(File.dirname(__FILE__) + "/..") { eval "Rack::Builder.new {( " + File.read("config.ru") + "\n )}" }

@knzai
Copy link
Author

knzai commented May 28, 2010

Yeah, good idea. In this usage I was handling all my dirname stuff within the app, but not a bad precaution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment