Use Form_for Or Simple_form_for Methods Without Any Form Tag In Rails

Posted By Weston Ganger

I wanted to use the form_for or simple_form_for input helpers without having a form tag.

I never thought you could use fields_for outside of form_for but you definitely can.

- fields_for @user do |f|
  = f.label :name, "Name"
  = f.text_field :email, "Email"

# OR If you use Simple_Form

- simple_fields_for @user do |f|
  = f.input :email

Now you can can have simple inputs that can be easily used anywhere.

Related External Links:

Article Topic:Software Development - Ruby / Rails

Date:April 28, 2016