Skip to content

Instantly share code, notes, and snippets.

@RJNY
Created February 21, 2018 15:12
Show Gist options
  • Save RJNY/332bf23881001af351ed1f65c9be6d74 to your computer and use it in GitHub Desktop.
Save RJNY/332bf23881001af351ed1f65c9be6d74 to your computer and use it in GitHub Desktop.
_form.html.erb corrections
<div class="form-group">
<%= form_with(model: product, local: true) do |form| %>
<% if product.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(product.errors.count, "error") %> prohibited this product from being saved:</h2>
<ul>
<% product.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= form.label :name %>
<%= form.text_field :name, id: :product_name, class: 'form-control' %>
</div>
<div class="field">
<%= form.label :description %>
<%= form.text_area :description, id: :product_description, class: 'form-control' %>
</div>
<div class="field">
<%= form.label :image_url %>
<%= form.text_field :image_url, id: :product_image_url, class: 'form-control' %>
</div>
<div class="field">
<%= form.label :color %><br>
<%= form.text_field :color, class: 'form-control' %>
</div>
<div class="field">
<%= form.label :price %><br>
<%= form.text_field :price, class: 'form-control' %>
</div>
<div class="actions">
<%= form.submit class: 'btn btn-default' %>
</div>
<% end %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment