0

undefined method `escape' for URI:Module

  URI.escape(value, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
     ^^^^^^^
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
            <%= render "devise/shared/error_messages", resource: resource %>
            <div class="modal-body p-5 pt-0">
                <form class="">
                    <div class="form mb-3">
                        <div class="row">
                            <div class="col-sm-4">
                                <%if resource.avatar.attached? %>
                                <%= image_tag resource.avatar.variant(resize: "100x100!"), class: "rounded-circle" %>
                                <%else%>

                                <%= image_tag gravatar_image_url(current_user.email, size: 100), class: "rounded-circle" %>

                                <%end%>
                            </div>

issue is here

<%= image_tag gravatar_image_url(current_user.email, size: 100), class: "rounded-circle" %>

Tried some option to resolve the escape but don't work at all. Not sure if this is the gravatar_image_tag gem issue or some issues with my setup.

Kamidesu
  • 111
  • 1
  • 9

1 Answers1

0

URI#escape was deprecated and later removed - https://github.com/ruby/uri/commit/61c6a47ebf1f2726b60a2bbd70964d64e14b1f98

From the commit :

# This method is obsolete and should not be used. Instead, use
# CGI.escape, URI.encode_www_form or URI.encode_www_form_component
# depending on your specific use case.

Ruby 3.0.0 onwards URI#escape does not work.

Use CGI.escape or URI.encode_www_form as mentioned in the deprecation note

Update

There is already a pull request raised on the gravatar_image_tag gems GitHub repository https://github.com/mdeering/gravatar_image_tag/pull/35

You can either fork the repository and use the gem from git

Or

create your own helper method as mentioned here - https://github.com/mdeering/gravatar_image_tag/pull/35#issuecomment-727137023

hash = Digest::MD5.hexdigest(email)
"https://secure.gravatar.com/avatar/#{hash}.png?height=#{size}&width=#{size}"
Deepak Mahakale
  • 22,834
  • 10
  • 68
  • 88