Defect #39756
closedActionView::Template::Error (undefined method `editable' for #<UserCustomField>
0%
Description
I try to add a custom field to a user which results in a "Internal Server Error"
Reproduce:- Open http://domain.tld/custom_fields/new?tab=IssueCustomField
- Select "Users"
- Click "Next"
- 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:- Redmine version 5.0.7.stable
- Ruby version 2.7.4-p191 (2021-07-07) [x86_64-linux-gnu]
- Rails version 6.1.7.6
- Environment production
- Database adapter Mysql2
- Mailer queue ActiveJob::QueueAdapters::AsyncAdapter
- Mailer delivery smtp
- additionals 3.0.8-main
- redmine_messenger 1.0.14
- redmine_spent_time 4.1.0
- view_customize 3.2.0
Anyone a suggestion what might be the problem?
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
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.
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.
Updated by Sven Culley 12 months ago
So what would be the correct way doing this with my current version?
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.
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?
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.
Updated by Pavel Rosický 12 months ago
it's a 15 year old migration (Redmine 0.9), but it's possible.
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?