New Project! 🎥 Export GIFs and Videos from FigmaTry it now

Quickly find where an asset is in Rails

June 18, 20131 min read

Rails AssetPipeline is a great feautre. However, sometimes it gets really confusing as to where a resource is located. Imagine you had to upgrade a basic library like jQuery UI on an older Rails project. How would you go about doing that if you can't simply find it as a gem in the gemfile and can't seem to find it anywhere in the project.

Below is a simple script you can paste into your rails console to find where the file is located. It will loop through all the directories rails uses for assets and try to find the file you specify.

paths = Rails.application.config.assets.paths
for path in paths do
    puts "Found in: #{path}" if Dir.glob("#{path}/*").grep(/jquery-ui/).present?

Enjoy :).

© 2022 Michael Yagudaev