Rails Sitemap
“When something is too hard, it means that you’re not cheating enough. it means that you’re doing it wrong“. Generating a Rails sitemap (hash of application controllers and actions) is as simple as placing and calling this method in your application:
def controllers_and_actions
require 'find'
site_map = {}
Find.find(RAILS_ROOT + '/app/controllers') do |file_name|
if /_controller.rb$/ =~ file_name
name = File.basename(file_name, ".rb")
site_map[name] = []
Object.const_get(name.classify).instance_methods(false).each do |act|
site_map[name] << act
end
end
end
site_map
end
Comments(2)