The generated rails index views from a scaffold look pretty bad. I understand it’s so that javascript replacement works but I think we can use divs with css table styling to have a much better default layout:
.css-table {
display: table;
width: 100%;
border-radius: 8px;
background-color: #343a40;
overflow: hidden;
.css-table-row {
display: table-row;
&.css-table-header {
font-weight: bold;
color: rgb(19, 217, 135);
background: #40474e;
border-top-right-radius: 8px;
border-top-left-radius: 8px;
}
&:last-child {
.css-table-cell {
border-bottom: none;
}
}
.css-table-cell {
display: table-cell;
padding: 0.75rem;
color: white;
text-align: center;
border-bottom: 1px solid #161616;
&:first-child {
width: 100%;
text-align: left;
}
}
}
}
You can then do something like:
<div class="css-table">
<div class="css-table-row css-table-header">
<div class="css-table-cell"></div>
<div class="css-table-cell">Members</div>
<div class="css-table-cell">Departments</div>
</div>
<% @organizations.each do |organization| %>
<div class="css-table-row organization-row">
<div class="css-table-cell"><%= link_to organization.name, organization_path(organization) %></div>
<div class="css-table-cell"><%= organization.members.count %></div>
<div class="css-table-cell"><%= organization.departments_count %></div>
</div>
<% end %>
</div>
Note that this example code is specific to my layout and is meant as an example of an approach that could be used.