app/views/courses/show.html.haml
- provide(:title, @course.name)
- if policy(@unit).create?
= modal :create_unit do
%h2 Create Unit
= simple_form_for @unit do |f|
= f.input :number
= f.input :name
= f.hidden_field :course_id
= f.button :submit
.row
- breadcrumb :course, @course
%h1= @course.name
%h3 Units
- if policy(@unit).create?
= modal_link "Create Unit", :create_unit, class: "button right"
%table
%thead
%tr
%th Number
%th Name
- if policy(@unit).edit? or policy(@unit).destroy?
%th Actions
%tbody
- policy_scope(@units).each do |u|
%tr
%td= link_to u.number, u
%td= u.name
- if policy(u).edit? or policy(u).destroy?
%td
= link_to "Edit", edit_unit_path(u) if policy(u).edit?
= link_to "Delete", u, method: :delete,
data: { confirm: "Are you sure you want to permanently delete #{ u.name }?" } if policy(u).destroy?