Created
June 26, 2011 21:46
-
-
Save lxcodes/1048003 to your computer and use it in GitHub Desktop.
Sinatra Load Routes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'bundler' | |
Bundler.require | |
require './app' | |
run app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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