jclem/active_record_rollout

View on GitHub
app/views/detour/flaggable_flags/index.html.erb

Summary

Maintainability
Test Coverage
<h1><%= flaggable_type.classify.pluralize %> <%= flag_verb %> <%= feature_name %></h1>

<% if @feature.errors.any? %>
  <div class="panel panel-danger">
    <div class="panel-heading">Whoops! There were some errors saving your <%= flag_noun.pluralize %>:</div>

    <div class="panel-body">
      <ul>
        <% @feature.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
      </ul>
    </div>
  </div>
<% end %>

<%= form_for @feature, url: request.path do |form| %>
  <%= form.fields_for "#{flaggable_type}_#{flag_type.pluralize}" do |flaggable_flag_form| %>
    <%= render "flaggable_flag_fields", f: flaggable_flag_form %>
  <% end %>

  <%= link_to_add_fields "Add #{flag_noun.capitalize}", form, "#{flaggable_type}_#{flag_type.pluralize}", :flaggable_flag_fields %>

  <hr>

  <%= form.submit "Update #{flag_noun.capitalize.pluralize}", class: "btn btn-primary pull-left" %>
<% end %>