Dan Stutzman

How to use Rails form helpers from Sinatra

Published 2013-07-19

Sinatra apparently has a couple form helper gems:

See also a StackOverflow question asking about form helper libraries.

The class I teach is learning Sinatra mainly as a stepping-stone to Rails, so it's more convenient to just use the Rails form helpers directly, by including the following lines in the Sinatra source code:

          require 'action_view' # for Rails form helpers
          # for Rails form helpers
          helpers ActionView::Helpers::FormTagHelper

Now form helpers like text_field_tag are available to your views.