Skip to content

Instantly share code, notes, and snippets.

@lxcodes
Created June 26, 2011 21:46
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 lxcodes/1048003 to your computer and use it in GitHub Desktop.
Save lxcodes/1048003 to your computer and use it in GitHub Desktop.
Sinatra Load Routes
# encoding: utf-8
class app < Sinatra::Application
Dir.glob('./routes/*').each { |r| require File.expand_path(File.join(File.dirname(__FILE__), r)) }
Dir.glob('./models/*').each { |r| require File.expand_path(File.join(File.dirname(__FILE__), r)) }
end
require 'rubygems'
require 'bundler'
Bundler.require
require './app'
run app
class User < app
# return list of all installed tasks. Just get all tasks and
# return as JSON
get '/users' do
content_type 'application/json'
{ 'content' => Array(User.all) }.to_json
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment