Skip to content

Commit bfb324a

Browse files
committed
Match templates to rails main branch
1 parent e48dc28 commit bfb324a

File tree

4 files changed

+34
-35
lines changed

4 files changed

+34
-35
lines changed

lib/templates/erb/scaffold/_form.html.erb.tt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
<%% end %>
1313

1414
<% attributes.each do |attribute| -%>
15-
<div class="field my-5">
15+
<div class="my-5">
1616
<% if attribute.password_digest? -%>
1717
<%%= form.label :password %>
1818
<%%= form.password_field :password %>
1919
</div>
2020

21-
<div class="field my-5">
21+
<div class="my-5">
2222
<%%= form.label :password_confirmation %>
2323
<%%= form.password_field :password_confirmation, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
2424
<% elsif attribute.attachments? -%>
@@ -37,7 +37,7 @@
3737
</div>
3838

3939
<% end -%>
40-
<div class="actions inline">
40+
<div class="inline">
4141
<%%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium" %>
4242
</div>
43-
<%% end %>
43+
<%% end %>

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

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,11 @@
44
<%% end %>
55

66
<div class="flex justify-between items-center">
7-
<h1 class="text-lg font-bold text-4xl"><%= human_name %></h1>
7+
<h1 class="text-lg font-bold text-4xl"><%= human_name.pluralize %></h1>
88
<%%= link_to 'New <%= human_name.downcase %>', new_<%= singular_route_name %>_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
99
</div>
1010

11-
<table class="min-w-full">
12-
<thead class="border-b-2 border-gray-200">
13-
<tr class="text-gray-500 uppercase text-left">
14-
<% attributes.reject(&:password_digest?).each do |attribute| -%>
15-
<th class="pt-6 pb-2 font-normal"><%= attribute.human_name %></th>
16-
<% end -%>
17-
</tr>
18-
</thead>
19-
20-
<tbody>
21-
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
22-
<tr class="align-top border-b border-gray-200">
23-
<% attributes.reject(&:password_digest?).each do |attribute| -%>
24-
<td class="py-6 pr-3"><%%= <%= singular_table_name %>.<%= attribute.column_name %> %></td>
25-
<% end -%>
26-
<td class="py-6 pr-3"><%%= link_to 'Show', <%= model_resource_name %>, class: "rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %></td>
27-
<td class="py-6 pr-3"><%%= link_to 'Edit', edit_<%= singular_route_name %>_path(<%= singular_table_name %>), class: "rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %></td>
28-
</tr>
29-
<%% end %>
30-
</tbody>
31-
</table>
11+
<div id="<%= plural_table_name %>" class="min-w-full">
12+
<%%= render @<%= plural_table_name %> %>
13+
</div>
3214
</div>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div id="<%%= dom_id <%= singular_table_name %> %>">
2+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
3+
<p class="my-5">
4+
<strong class="block font-medium mb-1"><%= attribute.human_name %>:</strong>
5+
<% if attribute.attachment? -%>
6+
<%%= link_to <%= singular_table_name %>.<%= attribute.column_name %>.filename, <%= singular_table_name %>.<%= attribute.column_name %> if <%= singular_table_name %>.<%= attribute.column_name %>.attached? %>
7+
<% elsif attribute.attachments? -%>
8+
<%% <%= singular_table_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>
9+
<div><%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %></div>
10+
<%% end %>
11+
<% else -%>
12+
<%%= <%= singular_table_name %>.<%= attribute.column_name %> %>
13+
<% end -%>
14+
</p>
15+
16+
<% end -%>
17+
<%% if action_name != "show" %>
18+
<%%= link_to "Show this <%= human_name.downcase %>", <%= singular_table_name %>, class: "rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
19+
<%%= link_to 'Edit this <%= human_name.downcase %>', edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %>
20+
<hr class="mt-6">
21+
<%% end %>
22+
</div>

lib/templates/erb/scaffold/show.html.erb.tt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%%= notice %></p>
55
<%% end %>
66

7-
<% attributes.reject(&:password_digest?).each do |attribute| -%>
8-
<p class="my-5">
9-
<strong class="block font-medium mb-1"><%= attribute.human_name %>:</strong>
10-
<%%= @<%= singular_table_name %>.<%= attribute.column_name %> %>
11-
</p>
12-
<% end -%>
7+
<%%= render @<%= singular_table_name %> %>
138

14-
<%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
9+
<%%= link_to 'Edit this <%= singular_table_name %>', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
1510
<div class="inline-block ml-2">
16-
<%%= button_to 'Delete', <%= singular_table_name %>_path(@<%= singular_table_name %>), method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
11+
<%%= button_to 'Delete this <%= singular_table_name %>', <%= singular_table_name %>_path(@<%= singular_table_name %>), method: :delete, data: { confirm: "Are you sure you want to delete this <%= singular_table_name %>?" }, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
1712
</div>
18-
<%%= link_to 'Back', <%= index_helper %>_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
13+
<%%= link_to 'Back to <%= plural_table_name %>', <%= index_helper %>_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
1914
</div>
2015
</div>

0 commit comments

Comments
 (0)