未定义的方法`逃逸'对于URI:Ruby 3中的模块
在将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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决这种情况的解决方案对库中的丢失方法进行了修补。
在初始化器文件夹中添加Ruby Filke Uri_escape.rb:
添加猴子补丁的行:
及其完成。
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:
and its done.
如果您由于现在被剥夺的“纸卷”宝石而遇到了这个问题,并且您不想切换到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.