【问题标题】:Getting frequent "Redmine 500 Error" by 'undefined method' after Downgrading Ruby and Rails降级 Ruby 和 Rails 后,“未定义方法”频繁出现“Redmine 500 错误”
【发布时间】:2018-03-23 05:31:46
【问题描述】:

由于应用了插件,我尝试将 Ruby 版本从 2.5.0 更改为 2.4.1,并将 Rails 版本从 5.1.2 更改为 4.2.1。

环境:

Redmine 版本 - 3.4.4.devel

Ruby 版本 - 2.4.1-p111 (2017-03-22) [x86_64-darwin16]
Rails 版本 - 4.2.8

环境 - 生产

数据库适配器 - Mysql2

我是 Ruby on Rails 的新手。我应该在这里做什么?

ActionView::Template::Error (undefined method `public_compute_asset_path' for #<#<Class:0x007f86344e0180>:0x007f86344d0f78>):
  config/initializers/10-patches.rb:221:in `rails_asset_id'

NoMethodError (undefined method `saved_change_to_parent_id?' for #<Project:0x00007fe5c80586f0>):
  app/models/project.rb:83:in `block in <class:Project>'
  app/controllers/projects_controller.rb:187:in `update'

NoMethodError (undefined method `saved_change_to_sharing?' for
#<Version:0x00007fe5c88d8870> Did you mean?  saved_attachments):
  app/models/version.rb:371:in `update_issues_from_sharing_change'
  app/controllers/versions_controller.rb:125:in `update'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

【问题讨论】:

  • undefined method ``public_compute_asset_path' 你更新了你的routes。这似乎是一个路由错误或配置错误。也许这是一个已知问题redmine.org/boards/2/topics/48375
  • 我在 Rails API 上搜索了 public_compute_asset_path,并将 path = File.join(Rails.public_path, **public_compute_asset_path**("#{source}#{extname}", options)) 更改为 path = File.join(Rails.public_path, **asset_path**("#{source}#{extname}", options))。现在它看起来可以工作了,但我不断收到 NoMethodError (undefined method saved_change_to_sharing?' for #&lt;Version:0x00007fe5c88d8870&gt;NoMethodError (undefined method saved_change_to_parent_id? for #&lt;Project:0x00007fe5c80586f0&gt;): 等....
  • Redmine 3.4.4 与 Rails 5 不兼容。插件通常与特定版本的 Redmine 兼容,而不是与 Rails 版本兼容。

标签: ruby-on-rails redmine webrick


【解决方案1】:

我知道如何解决“未定义的方法”!

首先,检查“未定义方法”是否存在并正确引用。有时源文件可能会丢失。

其次,如果'undefined method'是Rails方法(可以搜索),检查搜索到的方法是否与当前Redmine的Rails版本兼容。

我发现 public_compute_asset_path 存在于 Rails 版本 5 中。 我当前的 Redmine 的 Rails 版本设置为 4,Rails 4 使用 asset_path 而不是 public_compute_asset_path

因此,我将 Redmine 的 rails 版本更改为 Rails 5.1.2,它运行良好。

我的好奇心是官方 Redmine 网站指示将 Rails 4.2 用于 Redmine 3.4,但它适用于 Rails 5.1...

【讨论】:

  • Redmine 始终需要在其发行版的Gemfile 中指定的确切 Rails 版本。您永远不必自己更改Gemfile。如果你这样做了,各种各样的事情都可能(并且可能会)出错。
  • @HolgerJust 我更改了Gemfile,因为某些 gem 没有正确安装在 Mac OS 上。这就是我最初使用 Rails 5.1.2 版本的原因。但是,最大的问题是存档config/initializers/10-patches.rb,它使用Rails version 5 中的public_compute_asset_path 方法。 Rails 4 使用compute_asset_path
猜你喜欢
  • 2022-12-30
  • 2021-04-14
  • 1970-01-01
  • 2015-11-08
  • 2017-07-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多