Search code examples
ruby-on-railsruby-on-rails-4bundler

Best way to search through the source code of all the gems for a project


I'm getting a warning on my console that i'd like to resolve. The problem is that i'm not sure which gem is causing this warning. What is the best way to search through the source for all the gems for a specific project.

Thanks


Solution

  • I usually do the following:

    cd `bundle show rails` # Go to the directory having rails gem content
    cd ..                  # Go one level up to the folder having all gems
    grep -ir escape_javascript *  # search for the required text in all files
    > actionview-4.1.6/lib/action_view/helpers/javascript_helper.rb:      def escape_javascript(javascript)
    > actionview-4.1.6/lib/action_view/helpers/javascript_helper.rb:      alias_method :j, :escape_javascript
    

    EDIT: The answer below by jrochkind is the correct answer; my answer is incorrect as it searches through all the gems installed in the system.