How to find out which gem a Rails helper comes from

#Programming, #Ruby on Rails

Here is how to find out which gem a Rails helper method comes from.

I came across an badly named helper in a Rails project with a Gemfile as long as my arm and needed to find out what arguments the helper method took. The helper was unhelpfully named icon making it very hard to guess which of the many frontend gems this was calling.

<%= icon 'twitter', wtf: 'are the args' %>

How can you find the gem name for this helper?

Ask the console.

Ruby has the source_location method on a Method instance and with Rails you can call a helper method really easily in the console. From there you can dig through the path and find the gem name and finally the documentation.

Blame font-awesome-sass for the name.