Skip to content

Instantly share code, notes, and snippets.

@juliend2
Created February 26, 2011 01:43
Show Gist options
  • Save juliend2/844837 to your computer and use it in GitHub Desktop.
Save juliend2/844837 to your computer and use it in GitHub Desktop.
config.ru for buggy session
require 'rubygems'
require 'bundler'
Bundler.require
require './src/APPNAME.rb'
# load the config files (this will be either ours locally or Heroku
dbconfig = YAML.load(File.read('config/database.yml'))
environment = ENV['DATABASE_URL'] ? 'production' :'development'
# attach to the DB and run the create method for the Blog app
APPNAME::Models::Base.establish_connection dbconfig[environment]
APPNAME.create if APPNAME.respond_to? :create
# loop through each folder in 'public' and mount it at '/subfolder-name', e.g. '/css' etc.
Dir.chdir('public') do
public_dirs = (Dir.glob("*").find_all{|entry| File::directory?(entry)}).collect{|dir| '/' + dir}
use Rack::Static, :urls => public_dirs, :root => 'public'
end
run APPNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment