Jan Catrysse
Jan Catrysse

Reputation: 11

Redmine 5 with Rails 6.1 is no longer rendering a template file from a plugin correctly, it outputs raw html

I am using the that_attachments_limit plugin on Redmine 5, available from Github.

When using Redmine 4, this all worked like a charm, but since the upgrade to a newer version of Redmine (and Rails) this is not working anymore.

In the file plugins/that_attachments_limit/app/views/attachments/_form.html.erb I have a line with this code:

<%= render file: "#{Rails.root}/app/views/attachments/_form.html.erb", locals: locals %>

Before the upgrade, this was including the _form.html.erb from the base application. After the update, it is outputting the plain text content of the file, like:

<% attachment_param ||= 'attachments' %>
<% attachment_format_custom_field ||= false %>
...

I tried using a template, but this is loading the plugin's views in a loop, and not the views from the base application.

<%= render template: "attachments/_form.html.erb", locals: locals %>

I assume the method used to include the original base system's _form.html.erb is just plain wrong, but I would not know how to easily resolve that issue.

Upvotes: 0

Views: 195

Answers (1)

Jan Catrysse
Jan Catrysse

Reputation: 11

Using the solution provided here: https://www.redmine.org/boards/3/topics/33949 was helpful.

I created a Gemfile with content gem 'render_parent', '~> 0.1.0' to use this function, and changed the code from:

<%= render file: "#{Rails.root}/app/views/attachments/_form.html.erb", locals: locals %>

to:

<%= render :parent, {:locals => locals} %>

Upvotes: 0

Related Questions