Read more

Use form_for without the enclosing form tag

Avatar
Arne Hartherz
October 21, 2010Software engineer at makandra GmbH

In rare cases you might need something like form_for Show archive.org snapshot (for using form builder methods on the resulting block element) but without the surrounding form. One such case would be updating some of a form's fields via XHR.

Illustration book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
Read more Show archive.org snapshot

You can simply use Rails' fields_for to do things like this in your views (HAML here):

- fields_for @user do |form|
  = form.label :email, 'E-Mail'
  = form.text_field :email

You will only receive the form content you gave, no hidden inputs including the authenticity token etc.

Posted by Arne Hartherz to makandra dev (2010-10-21 16:46)