How do I do html forms with sinatra?
ruby, sinatra
Solution
Yes, since Sinatra 0.9 you can use Rails-like nested parameters:
You just declare your form as:
<form>
<input ... name="post[title]" />
<input ... name="post[body]" />
<input ... name="post[author]" />
</form>
And then you just have to do:
@post = params[:post]
to fetch all the parameters in an object.
More information in Learn Ruby the Hard Way
Problem
Is there some utilities available so that I could easily encapsulate form fields passed in requests in an object or do I have to create it myself by parsing fields from params in every request?