Created
September 3, 2014 18:26
-
-
Save tiegz/1ce5b2ae4f4f2e9efefd to your computer and use it in GitHub Desktop.
Find unused rails routes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# There could likely be some false positives from this | |
Rails.application.routes.routes.select do |r| | |
name = r.defaults[:controller].to_s.classify + "Controller" | |
klass = name.constantize rescue nil | |
if klass.nil? | |
name = r.defaults[:controller].to_s.classify.pluralize + "Controller" | |
klass = name.constantize rescue nil | |
end | |
klass.nil? || !klass.action_methods.include?(r.defaults[:action]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment