Skip to content

Instantly share code, notes, and snippets.

@kethlinmil
Created March 7, 2017 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kethlinmil/d20f4c2d0efb7b8c3fc94d86b2f0da11 to your computer and use it in GitHub Desktop.
Save kethlinmil/d20f4c2d0efb7b8c3fc94d86b2f0da11 to your computer and use it in GitHub Desktop.
<%= "<%= form_for @#{singular_name} do |f| %%>" %>
<div class="row">
<div class="col-md-4">
<%= "<% if @#{singular_name}.errors.any? %%>" %>
<div id="error_explanation">
<%= "<h2><%= pluralize(@#{singular_name}.errors.count, 'error') %%>" %> prohibited this <%= class_name %> from being saved:</h2>
<ul class="list-unstyled">
<%= "<% @#{singular_name}.errors.full_messages.each do |message| %%>" %>
<%= "<li><%= message %%></li>" %>
<%= "<% end %%>" %>
</ul>
</div>
<%= "<% end %%>" %>
<% editable_attributes.each do |attribute| %>
<div class="form-group">
<%= "<%= f.label :#{attribute.name} %%>" %>
<%= "<%= f.#{attribute.field_type} :#{attribute.name}, class: \"form-control\" %%>" %>
</div>
<% end -%>
<%= "<%= f.submit 'Submit', class: \"btn btn-success\" %%>" %>
</div>
</div>
<%= "<% end %%>" %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment