Friday, September 20, 2024 3:57:39 AM
> settings

Customize


Authenticate

> _listing.html.erb
<%= turbo_frame_tag post.dom_id, class: "list-entry" do %>
  <div class="row">
    <div class="col-12 col-lg-10">
      <div class="title">
        <% if policy(:post).edit? %>
          <%= post.status_icon %>
        <% end %>

        <%= link_to post.title, post_path(post), class: "text-decoration-none", data: {turbo: false} %>
      </div>
      <small class="created">
        Created at <%= js_timestamp(post.created_at.iso8601) %>
        <% if policy(:post).edit? %>
          <br>
          Visible to <%= post.roles.map(&:name).to_sentence.presence || "nobody" %>
        <% end %>
      </small>

      <div class="summary">
        <%= post.summary %>
      </div>
    </div>

    <% if policy(:post).edit? || policy(:post).destroy? %>
      <div class="w-100 mb-3 d-lg-none d-block"></div>

      <div class="col-12 col-lg-2">
        <% if policy(:post).edit? %>
          <%= link_to "Edit",
                  edit_post_path(post),
                  class: "btn btn-outline-success w-100 mb-3",
                  data: {"turbo-frame": "turbo_modal"}
                %>
        <% end %>

        <% if policy(:post).destroy? %>
          <%= button_to "Delete", post_path(post),
                  class: "btn btn-outline-danger w-100",
                  method: :delete
                %>
        <% end %>
      </div>
    <% end %>
  </div>
  <hr>
<% end %>
All opinions represented herein are my own
- © 2024 itsthedevman
- build 340fbb8