Redmine 升级后报错 ActionView::Template::Error (undefined method `default_assigned_to_id’

17年7月份安装的3.3.3-1版,然后2018年5月底安装了Redmine 3.4.5.stable,将之前的备份数据恢复后一切看起来都正常,然后用了1天发现项目的配置功能缺少了很多功能,并提示下面的错误信息:

1
2
3
4
5
6
7
Internal error
An error occurred on the page you were trying to access.
If you continue to experience problems please contact your Redmine administrator for assistance.

If you are the Redmine administrator, check your log files for details about the error.

Back

查看log

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Started GET "/redmine/projects/xxx/settings" for 127.0.0.1 at 2018-05-31 11:05:10 +0800
Processing by ProjectsController#settings as HTML
Parameters: {"id"=>"tos"}
Current user: wen (id=5)
Rendered projects/_form.html.erb (122.9ms)
Rendered projects/_edit.html.erb (124.3ms)
Rendered common/_tabs.html.erb (129.3ms)
Rendered projects/settings.html.erb within layouts/base (130.0ms)
Completed 500 Internal Server Error in 152ms (ActiveRecord: 8.3ms)

ActionView::Template::Error (undefined method `default_assigned_to_id' for #<Project:0x000055e1caabc230>
Did you mean? default_assigned_to
default_assigned_to=):
25: <% end %>
26:
27: <% if @project.safe_attribute?('default_assigned_to_id') && (default_assigned_to_options = project_default_assigned_to_options(@project)).present? %>
28: <p><%= f.select :default_assigned_to_id, default_assigned_to_options, include_blank: true %></p>
29: <% end %>
30:
31: <%= wikitoolbar_for 'project_description' %>
lib/redmine/views/labelled_form_builder.rb:38:in `select'
app/views/projects/_form.html.erb:28:in `_app_views_projects__form_html_erb__2075147363725627665_69885452907180'
app/views/projects/_edit.html.erb:2:in `block in _app_views_projects__edit_html_erb__2142230634445158885_69885452980800'
app/helpers/application_helper.rb:1190:in `labelled_form_for'
app/views/projects/_edit.html.erb:1:in `_app_views_projects__edit_html_erb__2142230634445158885_69885452980800'
app/views/common/_tabs.html.erb:17:in `block in _app_views_common__tabs_html_erb___547208032148431950_69885453651660'
app/views/common/_tabs.html.erb:16:in `each'
app/views/common/_tabs.html.erb:16:in `_app_views_common__tabs_html_erb___547208032148431950_69885453651660'
app/helpers/application_helper.rb:345:in `render_tabs'
app/views/projects/settings.html.erb:3:in `_app_views_projects_settings_html_erb___154138532272414153_69885453992440'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'

这是在官网找到的一些解决办法

http://www.redmine.org/boards/2/topics/53364

http://www.redmine.org/issues/26485

http://www.redmine.org/projects/redmine/repository/entry/tags/3.4.2/db/migrate/20170309214320_add_project_default_assigned_to_id.rb

原因是升级后数据库有变化,需要执行一个脚本对数据库修正。

1
sh /opt/redmine-3.4.5-0/apps/redmine/scripts/redmineini.sh

脚本里的内容:

1
2
3
4
5
6
. /opt/redmine-3.4.5-0/scripts/setenv.sh
cd /opt/redmine-3.4.5-0/apps/redmine/htdocs
bin/rake generate_secret_token
bin/rake db:migrate RAILS_ENV="production"

bin/rake redmine:load_default_data RAILS_ENV="production" REDMINE_LANG="zh"