6

Upgrading a Rails 5.2 project to Rails 6. After the upgrade, when I try to pull up the site, I'm getting the following error:

Can't resolve image into URL: undefined method `start_with?' for /\.(?:svg|eot|woff|ttf)$/:Regexp

This is code:

def source_image(source)
    if source == 'blah'
        return image_tag 'blah.png', size: '18', :title => 'blah', :data => {:toggle => 'tooltip', :placement => 'right', }
    end
end
Vasilisa
  • 4,604
  • 3
  • 20
  • 25
rip747
  • 9,375
  • 8
  • 36
  • 47
  • Are you sure that the error goes from the `source_image` method? Could you please post the whole error text in the question? – Vasilisa Mar 15 '20 at 16:06

1 Answers1

11

Visit config/initializer/assets.rb

Change

Rails.application.config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/

To This

Rails.application.config.assets.precompile << ["*.svg", "*.eot", "*.woff", "*.ttf"]
Rubyist
  • 6,486
  • 10
  • 51
  • 86
noooooob
  • 211
  • 2
  • 7
  • This solution worked for me. It would be useful if somebody could explain why this change was needed. – DeeBee Feb 16 '23 at 10:01