Skip to content

Instantly share code, notes, and snippets.

@rdavila
Created October 8, 2011 19:25
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 rdavila/1272745 to your computer and use it in GitHub Desktop.
Save rdavila/1272745 to your computer and use it in GitHub Desktop.
class JsonOnRack
def call(env)
if m = env['PATH_INFO'].match(/load_cities\/(\d)+/)
cities = City.select([:id, :name]).where(:state_id => m[1]).as_json
[
200,
{"Content-Type" => 'text/plain'},
[cities]
]
elsif m = env['PATH_INFO'].match(/load_zip_codes\/\d+/)
[
200,
{"Content-Type" => 'text/plain'},
['Ok']
]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment