Skip to content

Instantly share code, notes, and snippets.

@rafaelss
Created February 26, 2010 04:16
Show Gist options
  • Save rafaelss/315393 to your computer and use it in GitHub Desktop.
Save rafaelss/315393 to your computer and use it in GitHub Desktop.
# implementacao
def metodo_que_gera_uma_url(text_qualquer, params = {})
# ... inicializa algumas coisas
query = params.collect { |k, v| "#{k}=#{v}" }.join('&')
url << "?#{query}"
end
# teste
assert_equal "http://host_qualquer.com/?a=1&b=2", metodo_que_gera_uma_url("texto", :a => 1, :b => 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment