leonhooijer/zadok

View on GitHub
app/views/zadok/edit.html.slim

Summary

Maintainability
Test Coverage
.container.resource-edit[id="#{controller_name}-edit"]
  .card
    h2.card-header
      = page_title
      - if can?(:index, resource_class)
        = link_to(t("zadok.index.action", model: resource_name(:other)),
                resource_url_for(:index),
                class: "btn btn-primary text-white float-right")

    .card-body
      = form_for(resource,
                 url: resource_url_for(:update),
                 html: { autocomplete: "off" }) do |form|
        - edit_attributes.each do |attr, options|
          = render("zadok/form/fields/#{options[:type]}",
                   resource: resource,
                   form: form,
                   attr: attr,
                   options: options)

        .form-group
          = form.submit(class: "btn btn-primary text-white")

    - if can?(:destroy, resource)
      .card-footer
        = link_to(t("zadok.destroy.action", model: resource_name),
                  resource_url_for(:destroy),
                  data: { confirm: t("zadok.destroy.confirm", model: resource_name) },
                  method: :delete,
                  class: "btn btn-danger float-right")