-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathshow.html.erb
More file actions
122 lines (105 loc) · 4.11 KB
/
show.html.erb
File metadata and controls
122 lines (105 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<h1>
<%= singular_table_name.humanize %> #<%%= @the_<%= singular_table_name %>.id %> details
</h1>
<div>
<a href="/<%= plural_table_name %>">
Go back
</a>
</div>
<% unless read_only? -%>
<% if with_sentinels? -%>
<!-- Delete link <%= singular_table_name %> start -->
<% end -%>
<div>
<a href="/delete_<%= singular_table_name %>/<%%= @the_<%= singular_table_name %>.id %>">
Delete <%= singular_table_name.humanize.downcase %>
</a>
</div>
<% if with_sentinels? -%>
<!-- Delete link <%= singular_table_name %> end -->
<% end -%>
<% end -%>
<dl>
<% attributes.each do |attribute| -%>
<dt>
<%= attribute.human_name %>
</dt>
<% if with_sentinels? -%>
<!-- Display the_<%= attribute.column_name %> start -->
<% end -%>
<dd>
<%%= @the_<%= singular_table_name %>.<%= attribute.column_name %> %>
</dd>
<% if with_sentinels? -%>
<!-- Display the_<%= attribute.column_name %> end -->
<% end -%>
<% end -%>
<dt>
Created at
</dt>
<% if with_sentinels? -%>
<!-- Display created_at start -->
<% end -%>
<dd>
<%%= time_ago_in_words(@the_<%= singular_table_name %>.created_at) %> ago
</dd>
<% if with_sentinels? -%>
<!-- Display created_at end -->
<% end -%>
<dt>
Updated at
</dt>
<% if with_sentinels? -%>
<!-- Display updated_at start -->
<% end -%>
<dd>
<%%= time_ago_in_words(@the_<%= singular_table_name %>.updated_at) %> ago
</dd>
<% if with_sentinels? -%>
<!-- Display updated_at end -->
<% end -%>
</dl>
<hr>
<% if with_sentinels? -%>
<!-- Show Page Customization starts -->
<!-- Show Page Customization end -->
<% end -%>
<h2>
Edit <%= singular_table_name.humanize.downcase %>
</h2>
<form action="/modify_<%= singular_table_name %>/<%%= @the_<%= singular_table_name %>.id %>" <% unless skip_post? -%> method="post" <% end -%>>
<% attributes.each do |attribute| -%>
<% if attribute.field_type == :check_box -%>
<div>
<input type="checkbox" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" value="1" <%%= "checked" if @the_<%= singular_table_name %>.<%= attribute.column_name %> %>>
<label for="<%= attribute.column_name %>_box">
<%= attribute.column_name.humanize %>
</label>
</div>
<% else -%>
<div>
<label for="<%= attribute.column_name %>_box">
<%= attribute.column_name.humanize %>
</label>
<% if attribute.field_type == :text_area -%>
<textarea id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>"><%%= @the_<%= singular_table_name %>.<%= attribute.column_name %> %></textarea>
<% elsif attribute.field_type.to_s.gsub(/_.*/, "").to_sym == :datetime -%>
<input type="datetime-local" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>"
value="<%%= @the_<%= singular_table_name %>.<%= attribute.column_name %> %>">
<% elsif attribute.field_type.to_s.gsub(/_.*/, "").to_sym == :date -%>
<input type="date" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" value="<%%= @the_<%= singular_table_name %>.<%= attribute.column_name %> %>">
<% elsif attribute.field_type.to_s.gsub(/_.*/, "").to_sym == :time -%>
<input type="time" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" value="<%%= @the_<%= singular_table_name %>.<%= attribute.column_name %> %>">
<% elsif attribute.field_type.to_s.gsub(/_.*/, "").to_sym == :integer -%>
<input type="number" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" value="<%%= @the_<%= singular_table_name %>.<%= attribute.column_name %> %>">
<% else -%>
<input type="text" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" value="<%%= @the_<%= singular_table_name %>.<%= attribute.column_name %> %>">
<% end -%>
</div>
<% end -%>
<% end -%>
<button>
Update <%= singular_table_name.humanize.downcase %>
</button>
</form>
<hr>