Created
August 15, 2011 19:48
-
-
Save fabiokr/1147617 to your computer and use it in GitHub Desktop.
Retrieve a list of Rails 3 Controllers (or any other entities)
This file contains 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
# Replace "app/controllers" for the kind of thing you are looking for | |
# A list of available items can be found in rails/railties/lib/rails/engine/configuration.rb#line39 | |
Rails.configuration.paths["app/controllers"].expanded.inject([]) do |controllers, dir| | |
controllers += Dir["#{dir}/**/*_controller.rb"].map do |file| | |
file.gsub("#{dir}/", "") | |
.gsub(".rb", "") | |
.camelize | |
.constantize | |
end | |
end.uniq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment