NoMethodError Undefined用于`modify`的格式`:String

问题描述 投票:1回答:1

我在PurchaseOrdersController中有一个名为“modify”的方法,它在视图目录中也有它的模板(modify.slim)。

让我们说,我正在这条路上http://localhost:3000/purchase_orders/modify?prid=1

问题是,当我要点击打开newtab的锚标签('/po/1.pdf')时,:

NoMethodError (undefined method formats for "modify":String Did you mean? form_tag):

当我点击刷新页面http://localhost:3000/purchase_orders/modify?prid=1时发生。

有谁有想法如何解决这个问题?我正在使用Rails 5.2.1。

谢谢。

更新:请参阅Rails LogsCode: Controller, View

ruby-on-rails routes format ruby-on-rails-5 nomethoderror
1个回答
1
投票

为了让Rails正确加载文件,请确保您所包含的所有模块都在相应的类中完成。例如:

class MyClass
  include ActionView::Helpers
end

this post for more details

© www.soinside.com 2019 - 2024. All rights reserved.