未定义的方法`逃逸'对于URI:Ruby 3中的模块

发布于 2025-01-23 19:49:53 字数 390 浏览 4 评论 0原文

在将Rails应用程序从Rails 6.0.1更新为Rails 7.0.2.3之后,

我会发现GEM“ Paperclip”,'〜> 6.1.0'

在应用程序中使用它时给出了错误:

ActionView::Template::Error (undefined method `escape' for URI:Module
Did you mean?  escape_once):

我的应用程序中的用法:

<%= image_tag current_user.image.url('med'), width: "36px" %>

在Ruby Gemfile本身中存在错误时如何解决此问题,谢谢。

After updating my Rails application from Rails 6.0.1 to Rails 7.0.2.3

I am getting issue with the gem "paperclip", '~> 6.1.0'

while using it in application is gives error:

ActionView::Template::Error (undefined method `escape' for URI:Module
Did you mean?  escape_once):

Usage in my application:

<%= image_tag current_user.image.url('med'), width: "36px" %>

How to resolve this issue when bug is present in the ruby gemfile itself, thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

生生漫 2025-01-30 19:49:53

解决这种情况的解决方案对库中的丢失方法进行了修补。

在初始化器文件夹中添加Ruby Filke Uri_escape.rb:

添加猴子补丁的行:

module URI
  def self.escape(url)
    encode_www_form_component(url)
  end
end

及其完成。

The solution to this situation do a monkey patching to the missing method in library.

add a ruby filke uri_escape.rb inside the initializers folder:

add lines for monkey patching:

module URI
  def self.escape(url)
    encode_www_form_component(url)
  end
end

and its done.

伴随着你 2025-01-30 19:49:53

如果您由于现在被剥夺的“纸卷”宝石而遇到了这个问题,并且您不想切换到Activestorage,则有一个解决方案:
kt-paperclip gem( https://rubygems.org/gems.org/gems/kt-paperplip )是圆头形的叉子。

他们已经解决了这个URI问题,并且切换到KT-Paperclip将解决上述回形针错误,并允许您继续而无需迁移到Activestorage。

If you are having this problem due to the now-deprecated "paperclip" gem, and you don't want to switch to ActiveStorage yet, there is a solution:
The kt-paperclip gem (https://rubygems.org/gems/kt-paperclip) is a fork of Paperclip.

They have fixed this URI issue and switching to kt-paperclip will solve the above paperclip error and allow you to continue without migrating to ActiveStorage.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文