Last Updated: February 25, 2016
·
13.87K
· martinhaynes

Rails , HAML and form_tag

When using HAML as the template language in Ruby on Rails , don't forget the do

This won't work (even though in the docs it saids it will)

=form_tag(controller: :search , action: :query)
        .search_field
          =text_field_tag :q
          =button_tag 'Go' , class: 'search-button' , type: :submit

Instead you will need to do

=form_tag(controller: :search , action: :query) do
  .search_field
    =text_field_tag :q
    =button_tag 'Go' , class: 'search-button' , type: :submit

Otherwise the HAML Parse fails :(