Project

General

Profile

Actions

Defect #33183

closed

Unable to edit user or group that has custom fields with text formatting enabled

Added by Go MAEDA almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Custom fields
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Steps to reproduce:

1. Add a text format UserCustomField
2. Enable "Text formatting" for the custom field
3. Try to edit any user. You will see the Internal Server Error page

Completed 500 Internal Server Error in 145ms (ActiveRecord: 4.4ms)

ActionView::Template::Error (undefined method `project' for #<User:0x00007fafaefe19a0>
Did you mean?  projects
               projects=):
    18:   <% end %>
    19: 
    20:   <% @user.custom_field_values.each do |value| %>
    21:     <p><%= custom_field_tag_with_label :user, value %></p>
    22:   <% end %>
    23: 
    24:   <p><%= f.check_box :admin, :disabled => (@user == User.current) %></p>

app/helpers/custom_fields_helper.rb:89:in `custom_field_tag'
app/helpers/custom_fields_helper.rb:120:in `custom_field_tag_with_label'
app/views/users/_form.html.erb:21:in `block in _app_views_users__form_html_erb__1594929617543875487_70196358321500'
app/views/users/_form.html.erb:20:in `each'
app/views/users/_form.html.erb:20:in `_app_views_users__form_html_erb__1594929617543875487_70196358321500'
app/views/users/_general.html.erb:2:in `block in _app_views_users__general_html_erb___1757341575386637995_70196280622620'
app/helpers/application_helper.rb:1381:in `labelled_form_for'
app/views/users/_general.html.erb:1:in `_app_views_users__general_html_erb___1757341575386637995_70196280622620'
app/views/common/_tabs.html.erb:21:in `block in _app_views_common__tabs_html_erb__1281727382652852600_70196280567080'
app/views/common/_tabs.html.erb:20:in `each'
app/views/common/_tabs.html.erb:20:in `_app_views_common__tabs_html_erb__1281727382652852600_70196280567080'
app/helpers/application_helper.rb:457:in `render_tabs'
app/views/users/edit.html.erb:13:in `_app_views_users_edit_html_erb___3120376360499099218_70196265966740'
lib/redmine/sudo_mode.rb:64:in `sudo_mode'

Files

test_for_33183.patch (669 Bytes) test_for_33183.patch Marius BĂLTEANU, 2020-03-23 18:23

Related issues

Related to Redmine - Feature #31989: Inline issue auto complete (#) in fields with text-formatting enabledClosedGo MAEDA

Actions
Actions #1

Updated by Go MAEDA almost 5 years ago

This is due to r18444.

Actions #2

Updated by Go MAEDA almost 5 years ago

  • Related to Feature #31989: Inline issue auto complete (#) in fields with text-formatting enabled added
Actions #3

Updated by Marius BĂLTEANU almost 5 years ago

  • Assignee set to Marius BĂLTEANU
Actions #4

Updated by Go MAEDA almost 5 years ago

The following code fixes the issue.

diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb
index a6fbff9bd..26023ae94 100644
--- a/app/helpers/custom_fields_helper.rb
+++ b/app/helpers/custom_fields_helper.rb
@@ -86,7 +86,7 @@ module CustomFieldsHelper
       data = {
         :auto_complete => true,
         :issues_url => auto_complete_issues_path(:project_id => custom_value.customized.project, :q => '')
-      } if custom_value.customized && custom_value.customized.project
+      } if custom_value.customized && custom_value.customized.try(:project)
     end
     custom_value.custom_field.format.edit_tag(
       self,
Actions #5

Updated by Marius BĂLTEANU over 4 years ago

The fix looks good to me and I have attached a test case.

Thanks Go Maeda for detecting this issue.

Actions #6

Updated by Go MAEDA over 4 years ago

  • Subject changed from Cannot edit user if it has UserCustomField with text_formatting enabled to Unable to edit user or group that has custom fields with text formatting enabled
  • Status changed from New to Closed
  • Resolution set to Fixed

Committed the patch.

Actions

Also available in: Atom PDF