This should be an easy one, I'm a noob.
I have new and edit views for a model that use a partial to display a form. For the edit form I want to display a field that I do not want to display in the new form.
Should I be passing a local variable stating its in edit mode to the partial and use a condition in the partial to display the field?
Whats the best practice in this case to let the partial know what action called it?
This will only display the field for the new
form
<%# app/views/something/_form.html.erb %>
<% form_for something do |form| %>
<%# common fields ... %>
<% if something.new_record? %>
<%= form.text_field :foo %>
<% end %>
<% end %>
If you want it on the edit
form, just switch if
to unless
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With