Skip to content

Instantly share code, notes, and snippets.

@jlong
Forked from jcamenisch/config.ru
Created March 29, 2011 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlong/891821 to your computer and use it in GitHub Desktop.
Save jlong/891821 to your computer and use it in GitHub Desktop.
#\ -p 4000
gem 'activesupport'
gem 'serve'
require 'serve'
require 'serve/rack'
# The project root directory
root = ::File.dirname(__FILE__)
# Common Rack Middleware
use Rack::ShowStatus # Nice looking 404s and other messages
use Rack::ShowExceptions # Nice looking errors
if ENV['RACK_ENV'] == "production"
# Use Rack::Static with Heroku
use Rack::Static, :urls => ["/images", "/javascripts", "/stylesheets"], :root => "public"
run Serve::RackAdapter.new(root + '/views')
else
# Compile Sass on the fly
require 'sass/plugin/rack'
require 'compass'
Compass.add_project_configuration(root + '/compass.config')
Compass.configure_sass_plugin!
use Sass::Plugin::Rack
# Use Rack::Cascade and Rack::Directory to handle
# files in public directory gracefully
run Rack::Cascade.new([
Serve::RackAdapter.new(root + '/views'),
Rack::Directory.new(root + '/public')
])
end
@westlane
Copy link

Thank you! So much simpler than the Hassle hack I had going for Heroku, before.

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