Project

General

Profile

Actions

Defect #39756

closed

ActionView::Template::Error (undefined method `editable' for #<UserCustomField>

Added by Sven Culley 12 months ago. Updated 12 months ago.

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

0%

Estimated time:
Resolution:
Invalid
Affected version:

Description

I try to add a custom field to a user which results in a "Internal Server Error"

Reproduce:
  1. Open http://domain.tld/custom_fields/new?tab=IssueCustomField
    1. Select "Users"
  2. Click "Next"
  3. Error message is shown
[552a7584-417b-4565-833b-2a17aa22cb7e] ActionView::Template::Error (undefined method `editable' for #<UserCustomField:0x000055ca2a870678>
Did you mean?  edit_tag_style):
[552a7584-417b-4565-833b-2a17aa22cb7e]     39:     <% end %>
[552a7584-417b-4565-833b-2a17aa22cb7e]     40: 
[552a7584-417b-4565-833b-2a17aa22cb7e]     41:     <% if @custom_field.is_a?(UserCustomField) %>
[552a7584-417b-4565-833b-2a17aa22cb7e]     42:       <p><%= f.check_box :editable %></p>
[552a7584-417b-4565-833b-2a17aa22cb7e]     43:     <% end %>
[552a7584-417b-4565-833b-2a17aa22cb7e]     44: 
[552a7584-417b-4565-833b-2a17aa22cb7e]     45:     <% if %w(IssueCustomField UserCustomField ProjectCustomField VersionCustomField GroupCustomField TimeEntryCustomField).include?(@custom_field.class.name) &&
[552a7584-417b-4565-833b-2a17aa22cb7e]   
[552a7584-417b-4565-833b-2a17aa22cb7e] lib/redmine/views/labelled_form_builder.rb:36:in `check_box'
[552a7584-417b-4565-833b-2a17aa22cb7e] app/views/custom_fields/_form.html.erb:42
[552a7584-417b-4565-833b-2a17aa22cb7e] app/views/custom_fields/new.html.erb:4
[552a7584-417b-4565-833b-2a17aa22cb7e] app/helpers/application_helper.rb:1483:in `labelled_form_for'
[552a7584-417b-4565-833b-2a17aa22cb7e] app/views/custom_fields/new.html.erb:3
[552a7584-417b-4565-833b-2a17aa22cb7e] lib/redmine/sudo_mode.rb:61:in `sudo_mode'

Technical environment

Environment:
  1. Redmine version 5.0.7.stable
  2. Ruby version 2.7.4-p191 (2021-07-07) [x86_64-linux-gnu]
  3. Rails version 6.1.7.6
  4. Environment production
  5. Database adapter Mysql2
  6. Mailer queue ActiveJob::QueueAdapters::AsyncAdapter
  7. Mailer delivery smtp
Redmine plugins:
  1. additionals 3.0.8-main
  2. redmine_messenger 1.0.14
  3. redmine_spent_time 4.1.0
  4. view_customize 3.2.0

Anyone a suggestion what might be the problem?

Actions #1

Updated by Pavel Rosický 12 months ago

it looks like a missing migration https://github.com/redmine/redmine/blob/5.1-stable/db/migrate/102_add_custom_fields_editable.rb#L3

1/ check if the column exists in your database
2/ perhaps you forgot to restart the server
3/ try it without plugins

Actions #2

Updated by Sven Culley 12 months ago

https://github.com/redmine/redmine/blob/5.0-stable/db/migrate/102_add_custom_fields_editable.rb
I have added the "editable" column to the database manually by performing

ALTER TABLE custom_fields ADD editable boolean NOT NULL default true; 

After this the error is gone.

Actions #3

Updated by Holger Just 12 months ago

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

You should not manually edit your database; this is likely to cause database schema (and possibly also data-) inconsistencies which may make it very hard to later update Redmine. All database schema changes should be done ONLY by applying the defined migrations.

See RedmineUpgrade for details about upgrading.

Actions #4

Updated by Sven Culley 12 months ago

So what would be the correct way doing this with my current version?

Actions #5

Updated by Pavel Rosický 12 months ago

perhaps you've removed that column by mistake in the past? That's why you shouldn't change the database schema this way, it's hard to guess how this could happen.

anyway, it's your local database issue, not a Redmine bug.

Actions #6

Updated by Sven Culley 12 months ago

For what I know that has never happened. Using Redmine quite long now.

What can I do to fix this now?

Actions #7

Updated by Holger Just 12 months ago

You likely have forgotten to run database migrations when you last updated your Redmine installation.

Please refer to the RedmineUpgrade guide I linked to previously—esp. step 4—for how to run all pending database migrations.

In any case, you may want to create a full working database backup before you start to ensure you have a fallback in case some steps fail. See RedmineBackupRestore for details.

Actions #8

Updated by Pavel Rosický 12 months ago

it's a 15 year old migration (Redmine 0.9), but it's possible.

Actions #9

Updated by Sven Culley 12 months ago

Done step 4 of the update guide but nothing happened on the migration step. This is what I always do when updating Redmine.

So what should I do?

Actions

Also available in: Atom PDF