Skip to content

Commit f71a89d

Browse files
revert class reordering, add attachments links to table rows, fix hardcoded vars, add edit and destroy actions to table rows
1 parent 91e8705 commit f71a89d

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt

+19-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
<div class="w-full">
44
<%% if notice.present? %>
5-
<p class="inline-block px-3 py-2 mb-5 font-medium text-green-500 rounded-md bg-green-50" id="notice"><%%= notice %></p>
5+
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-md inline-block" id="notice"><%%= notice %></p>
66
<%% end %>
77

8-
<div class="flex items-center justify-between">
9-
<h1 class="text-4xl font-bold"><%= human_name.pluralize %></h1>
8+
<div class="flex justify-between items-center">
9+
<h1 class="font-bold text-4xl"><%= human_name.pluralize %></h1>
1010
<%%= link_to "New <%= human_name.downcase %>", new_<%= singular_route_name %>_path, class: "rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white block font-medium" %>
1111
</div>
1212

@@ -22,20 +22,34 @@
2222
</tr>
2323
</thead>
2424
<tbody class="divide-y divide-gray-200">
25-
<%% @users.each do |user| %>
25+
<%% @<%= plural_table_name %>.each do |<%= singular_name %>| %>
2626
<tr class="border-b">
2727
<% attributes.reject(&:password_digest?).each do |attribute| -%>
28+
<% if attribute.attachment? -%>
29+
<td class="py-4 whitespace-nowrap"><%%= link_to <%= singular_name %>.<%= attribute.column_name %>.filename, <%= singular_name %>.<%= attribute.column_name %> if <%= singular_name %>.<%= attribute.column_name %>.attached? %></td>
30+
<% elsif attribute.attachments? -%>
31+
<td class="py-4 whitespace-nowrap">
32+
<%% <%= singular_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>
33+
<div><%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %></div>
34+
<%% end %>
35+
</td>
36+
<% else -%>
2837
<td class="py-4 whitespace-nowrap"><%%= <%= singular_name %>.<%= attribute.column_name %> %></td>
38+
<% end -%>
2939
<% end -%>
3040
<td class="py-4 space-x-4 whitespace-nowrap">
3141
<%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "text-blue-600 hover:text-blue-900" %>
42+
<%%= link_to "Edit", edit_<%= singular_route_name %>_path(<%= singular_table_name %>), class: "text-blue-600 hover:text-blue-900" %>
43+
<div class="inline-block ml-2">
44+
<%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "text-red-600 hover:text-red-900" %>
45+
</div>
3246
</td>
3347
</tr>
3448
<%% end %>
3549
</tbody>
3650
</table>
3751
<%% else %>
38-
<p class="my-10 text-center">No <%= human_name.downcase.pluralize %> found.</p>
52+
<p class="text-center my-10">No <%= human_name.downcase.pluralize %> found.</p>
3953
<%% end %>
4054
</div>
4155
</div>

0 commit comments

Comments
 (0)