Project

General

Profile

Actions

Defect #32704

closed

ActionView::Template::Error (undefined method `position' for nil:NilClass):

Added by quancept quancept almost 5 years ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Documents
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Started GET "/redmine/projects/chinastockreceiver/documents" for 127.0.0.1 at 2019-12-27 20:12:30 +0800
Processing by DocumentsController#index as HTML
Parameters: {"project_id"=>"chinastockreceiver"}
Current user: xuxf (id=17)
Rendered attachments/_form.html.erb (15.7ms)
Rendered documents/_form.html.erb (31.3ms)
Rendered documents/index.html.erb within layouts/base (31.3ms)
Completed 500 Internal Server Error in 78.3ms

ActionView::Template::Error (undefined method `position' for nil:NilClass):
18:
19: <% if @grouped.empty? ><p class="nodata"><= l(:label_no_data) ></p>< end >
20:
21: <
@grouped.keys.sort.each do |group| >
22: <h3><
= group ></h3>
23: <
= render :partial => 'documents/document', :collection => @grouped[group] >
24: <
end %>
app/models/enumeration.rb:93:in `<=>'
app/views/documents/index.html.erb:21:in `sort'
app/views/documents/index.html.erb:21:in `_app_views_documents_index_html_erb__107423285_27756576'


Files

production.log (23.9 KB) production.log quancept quancept, 2019-12-27 13:59
32704.patch (1.77 KB) 32704.patch Go MAEDA, 2023-06-25 07:59

Related issues

Related to Redmine - Defect #10053: undefined method `<=>' for nil:NilClass when accessing the settings of a projectClosedJean-Philippe Lang

Actions
Related to Redmine - Patch #38772: <=> should return nil when invoked with an incomparable objectClosedGo MAEDA

Actions
Actions #1

Updated by Go MAEDA over 4 years ago

I am not sure why nil is passed to <=>, but I think the following patch should fix the problem.

diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb
index 4710fde81..a8ca08726 100644
--- a/app/models/enumeration.rb
+++ b/app/models/enumeration.rb
@@ -90,6 +90,7 @@ class Enumeration < ActiveRecord::Base
   end

   def <=>(enumeration)
+    return -1 if enumeration.nil?
     position <=> enumeration.position
   end

Actions #2

Updated by Go MAEDA over 4 years ago

  • Related to Defect #10053: undefined method `<=>' for nil:NilClass when accessing the settings of a project added
Actions #3

Updated by Go MAEDA over 1 year ago

  • Related to Patch #38772: <=> should return nil when invoked with an incomparable object added
Actions #4

Updated by Go MAEDA over 1 year ago

I think the data in your database is inconsistent. For example, you deleted document categories by directly using a DELETE statement of SQL. I succeeded to reproduce the error by deleting document categories with the following SQL.

delete from enumerations where type = 'DocumentCategory';

The attached patch fixes the issue by ignoring inconsistent data.

Actions #5

Updated by Go MAEDA 11 months ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Due to the changes made in #38772, passing nil to <=> no longer causes the exception to occur.

Actions

Also available in: Atom PDF