Created
October 26, 2011 21:50
-
-
Save canadaduane/1317995 to your computer and use it in GitHub Desktop.
Sinatra app_path, similar to uri/url/to but with optional params
This file contains hidden or 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
def app_path(path, params={}) | |
if params.size == 0 | |
uri(path) | |
else | |
query_string = "" | |
params.each_pair do |key, value| | |
query_string += key.to_s + '=' + escape(value.to_s) | |
end | |
uri(path) + '?' + query_string | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment