reubenmallaby / redmine_projects_accordion

Projects accordion view for Redmine
8 stars 12 forks source link

Internal Error, possibly caused by"delete_if" method #11

Open vergelli opened 3 years ago

vergelli commented 3 years ago

Hello, I'm having the following issue, and I really was wondering if there is an easy workaround for this. Here is the problem:

Platform: Inside a Docker container Redmine version: 4.2.1.stable DB: Postgres.

So I installed redmine_projects_accordion but when I go to the Projects view, an "Internal Error (500)" is triggered internal error

I went for my log file and I found the following:

redmine_1      | I, [2021-08-31T18:24:27.000867 #1]  INFO -- : Successful authentication for 'admin' from <ip> at 2021-08-31 18:24:27 UTC
redmine_1      | I, [2021-08-31T18:24:27.034072 #1]  INFO -- : Redirected to http://<ip>:3000/
redmine_1      | I, [2021-08-31T18:24:27.034268 #1]  INFO -- : Completed 302 Found in 58ms (ActiveRecord: 31.3ms)
redmine_1      | I, [2021-08-31T18:24:27.247062 #1]  INFO -- : Started GET "/" for <ip> at 2021-08-31 18:24:27 +0000
redmine_1      | I, [2021-08-31T18:24:27.248674 #1]  INFO -- : Processing by WelcomeController#index as HTML
redmine_1      | I, [2021-08-31T18:24:27.257705 #1]  INFO -- :   Current user: admin (id=1)
redmine_1      | I, [2021-08-31T18:24:27.261620 #1]  INFO -- :   Rendering welcome/index.html.erb within layouts/base
redmine_1      | I, [2021-08-31T18:24:27.264667 #1]  INFO -- :   Rendered welcome/index.html.erb within layouts/base (3.0ms)
redmine_1      | I, [2021-08-31T18:24:27.315254 #1]  INFO -- : Completed 200 OK in 66ms (Views: 50.4ms | ActiveRecord: 8.1ms)
redmine_1      | I, [2021-08-31T18:24:32.580770 #1]  INFO -- : Started GET "/projects" for <ip> at 2021-08-31 18:24:32 +0000
redmine_1      | I, [2021-08-31T18:24:32.581961 #1]  INFO -- : Processing by ProjectsController#index as HTML
redmine_1      | I, [2021-08-31T18:24:32.589716 #1]  INFO -- :   Current user: admin (id=1)
redmine_1      | I, [2021-08-31T18:24:32.654369 #1]  INFO -- :   Rendering plugins/redmine_projects_accordion/app/views/projects/index.html.erb within layouts/base
redmine_1      | I, [2021-08-31T18:24:32.662031 #1]  INFO -- :   Rendered plugins/redmine_projects_accordion/app/views/projects/index.html.erb within layouts/base (7.5ms)
redmine_1      | I, [2021-08-31T18:24:32.662299 #1]  INFO -- : Completed 500 Internal Server Error in 80ms (ActiveRecord: 13.9ms)
redmine_1      | F, [2021-08-31T18:24:32.663386 #1] FATAL -- :   
redmine_1      | F, [2021-08-31T18:24:32.663453 #1] FATAL -- : ActionView::Template::Error (undefined method `delete_if' for nil:NilClass):
redmine_1      | F, [2021-08-31T18:24:32.663652 #1] FATAL -- :     13: 
redmine_1      |     14: <h2><%=l(:label_project_plural)%></h2>
redmine_1      |     15: 
redmine_1      |     16: <% @projects.delete_if { |p| !p.active? } -%>
redmine_1      |     17: 
redmine_1      |     18: <% ids = @projects.map { |p| p.id } %> 
redmine_1      |     19: <%- #unless p.children.empty? } %>
redmine_1      | F, [2021-08-31T18:24:32.663689 #1] FATAL -- :   
redmine_1      | F, [2021-08-31T18:24:32.663719 #1] FATAL -- : plugins/redmine_projects_accordion/app/views/projects/index.html.erb:16:in `_plugins_redmine_projects_accordion_app_views_projects_index_html_erb__717125005942677875_113560'
redmine_1      | lib/redmine/sudo_mode.rb:61:in `sudo_mode'
redmine_1      | plugins/redmine_dmsf/lib/redmine_dmsf/webdav/custom_middleware.rb:56:in `call'

So I'm assuming there is a problem with a method called projects.delete_if. Of course, it could be something else but this is what my log is showing. I'm not an expert with ruby by the way, so I wonder if you can suggest me something. It appears that this method is not being recognized since it says: "undefined method delete_if' for nil:NilClass".

Any suggestion would be appreciated.

Regards.

alstonhuang commented 1 year ago

Hi, I found that after redmine 4.2, there are some if-eles path does not define @projects but only @entries. So I add one line into index.erb

<%=l(:label_project_plural)%>

<% @projects ||= @entries %>

<% @projects.delete_if { |p| !p.active? } -%>

and it works.

But the behavior is abnormal in redmine 5.0 and I am still trying out what's the problems.

  1. expand height does not fit the sub projects
  2. text color changes and it looks like the text is invisible when I expand the parent project.

Any suggestion would be appreciated,

Regards.