プロジェクト

全般

プロフィール

Vote #80040

完了

Explicitly load redmine/info in order to avoid "uninitialized constant" error

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Rails support_44
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
44
version_id:
151
issue_org_id:
31337
author_id:
5471
assigned_to_id:
332
comments:
4
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
99
ステータス-->[Closed]

説明

with Rails.env production, where we have:

  config.cache_classes = true
  config.eager_load = true

if you comment this line on lib/redmine.rb

  #menu.push :help, Redmine::Info.help_url, :last => true

accessing http://localhost:3000/admin/info crashes with

  uninitialized constant Redmine::Info
Did you mean?  TZInfo
  app/views/admin/info.html.erb:3:in `_app_views_admin_info_html_erb__3650592729958042480_47028059654180'

rails 5 does not autoload code in production and does not eager_load lib, so shouldn't lib files be moved to app? (or required in a initializer)


journals

Confirmed the problem in production mode.

<pre>
Started GET "/" for 127.0.0.1 at 2019-05-12 09:09:58 +0900
Processing by WelcomeController#index as HTML
Current user: anonymous
Rendering welcome/index.html.erb within layouts/base
Rendered collection of news/_news.html.erb [2 times] (3.2ms)
Rendered welcome/index.html.erb within layouts/base (4.8ms)
Completed 500 Internal Server Error in 34ms (ActiveRecord: 1.8ms)

ActionView::Template::Error (uninitialized constant Redmine::Info
Did you mean? TZInfo):
5: <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
6: <title><%= html_title %></title>
7: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
8: <meta name="description" content="<%= Redmine::Info.app_name %>" />
9: <meta name="keywords" content="issue,bug,tracker" />
10: <%= csrf_meta_tag %>
11: <%= favicon %>

app/views/layouts/base.html.erb:8:in `_app_views_layouts_base_html_erb___407490831146708261_70306253856560'
lib/redmine/sudo_mode.rb:65:in `sudo_mode'
</pre>

<pre><code class="diff">
diff --git a/lib/redmine.rb b/lib/redmine.rb
index 2de351c07..600b9df57 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -194,7 +194,7 @@ Redmine::MenuManager.map :top_menu do |menu|
menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? }
menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural
menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true
- menu.push :help, Redmine::Info.help_url, :last => true
+ # menu.push :help, Redmine::Info.help_url, :last => true
end

Redmine::MenuManager.map :account_menu do |menu|
</code></pre>

--------------------------------------------------------------------------------
The following patch fixes the problem.

<pre><code class="diff">
diff --git a/lib/redmine.rb b/lib/redmine.rb
index 7c06ac344..7e4f65370 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -40,6 +40,7 @@ require 'redmine/activity/fetcher'
require 'redmine/ciphering'
require 'redmine/codeset_util'
require 'redmine/field_format'
+require 'redmine/info'
require 'redmine/menu_manager'
require 'redmine/notifiable'
require 'redmine/platform'
</code></diff>

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed the fix. Thank you for reporting this issue.
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリRails support_44 にセット
  • 対象バージョン4.0.4_151 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0