0

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.

vidur punj
  • 3,120
  • 2
  • 35
  • 53
  • 1
    Does this answer your question? [Undefined method \`escape' for URI:Module](https://stackoverflow.com/questions/68174351/undefined-method-escape-for-urimodule) – Ken White Apr 25 '22 at 04:00
  • yes idea is in both mokey patching is the technique used. – vidur punj Apr 25 '22 at 10:54

1 Answers1

0

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 URI.escape(url)
    url
  end
end

and its done.

vidur punj
  • 3,120
  • 2
  • 35
  • 53