From 85a8bc644be69908f05740a5886ec19cd3679df5 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sat, 4 May 2019 09:14:10 +0900 Subject: Make generated test work even when using virtual attributes The virtual attributes(`attachment` and `rich_text`) can't set value with `fill_in`. So avoid using it. Once #35885 is merged, will be modified to use it. Also, add checking attachment attached or not for avoiding `DelegationError` when attachment didn't attach. --- railties/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails/generators/erb/scaffold/templates') diff --git a/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt b/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt index 6b216001d2..d3f996188c 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +++ b/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt @@ -4,7 +4,7 @@

<%= attribute.human_name %>: <% if attribute.attachment? -%> - <%%= link_to @<%= singular_table_name %>.<%= attribute.column_name %>.filename, @<%= singular_table_name %>.<%= attribute.column_name %> %> + <%%= link_to @<%= singular_table_name %>.<%= attribute.column_name %>.filename, @<%= singular_table_name %>.<%= attribute.column_name %> if @<%= singular_table_name %>.<%= attribute.column_name %>.attached? %> <% elsif attribute.attachments? -%> <%% @<%= singular_table_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>

<%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %>
-- cgit v1.2.3