Created
February 6, 2014 14:44
-
-
Save ryanbriones/8845507 to your computer and use it in GitHub Desktop.
Is there something in Ruby (in an existing gem?) that will take an HTML String, parse out a form, and return URI-encoded query string of the fields/values a la jQuery's form.serialize?
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
<form> | |
<input type="text" name="post[title]" value="Some Title" /> | |
<textarea name="post[body]">This is my post body</textarea> | |
</form> |
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
post[title]=Some%20Title&post[body]=This%20is%20my%20post%20body |
html = Nokogiri::HTML("...")
params = Capybara::RackTest::Form.new(nil, html).params({})
Rack::Utils.build_nested_query(params) #=> yay!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is what I've manually coded up: