Patch #32887

Rails 6: Use "render template:" instead of "render file:" in app/views/layouts/admin.html.erb

Added by Go MAEDA 2 months ago. Updated 2 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Rails support
Target version:4.2.0

Description

$ bin/rails test test/functional/admin_controller_test.rb
.
.
.
DEPRECATION WARNING: render file: should be given the absolute path to a file (called from _app_views_layouts_admin_html_erb___682843397516142584_70111060943800 at /path/to/redmine/app/views/layouts/admin.html.erb:8)

The behavior has changed by this commit:
https://github.com/rails/rails/commit/c7820d8124c854760a4d288334f185de2fb99446

According to the commit log, the only difference between render file: and render template: before Rails 6 is that render file: can specify the absolute path of templates.

app/views/layouts/admin.html.erb does not use an absolute path to specify the template, so you can suppress deprecation warning by replacing render file: with render template:.

diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb
index 8f23129b4..0ce74d104 100644
--- a/app/views/layouts/admin.html.erb
+++ b/app/views/layouts/admin.html.erb
@@ -5,4 +5,4 @@
   <% end %>
 <% end %>

-<%= render :file => "layouts/base" %>
+<%= render :template => 'layouts/base' %>
</diff>

Related issues

Related to Redmine - Feature #29914: Migrate to Rails 6 New

Associated revisions

Revision 19466
Added by Go MAEDA 2 months ago

Rails 6: Use "render template:" instead of "render file:" in app/views/layouts/admin.html.erb (#32887).

Patch by Go MAEDA.

History

#1 Updated by Go MAEDA 2 months ago

  • Subject changed from Rails 6: Use "render template" instead of "render file" in app/views/layouts/admin.html.erb to Rails 6: Use "render template:" instead of "render file:" in app/views/layouts/admin.html.erb
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Target version set to 4.2.0

Committed the patch.

#2 Updated by Go MAEDA 2 months ago

Also available in: Atom PDF