hi, I am trying to collect all controllers names in application. how to get directory contents under /app/controllers/ any1 have any idea I look up the File & FileUtils classes, but cant find anything thanks serz -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
def find_controller_names
        a = []
        Find.find( RAILS_ROOT + ''/app/controllers'' ) do
|file_name|
                if /.rb$/ =~ file_name
                a <<
File.basename(file_name).gsub(''.rb'',
'''').camelcase
                end
        end
        render_text a.inspect
end
if you run find_controller_names, you''ll get something like
["Application", "SomeController",
"OtherController"]
hope it helps!
:)
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Shai Rosenfeld wrote:> def find_controller_names > a = [] > Find.find( RAILS_ROOT + ''/app/controllers'' ) do |file_name| > if /.rb$/ =~ file_name > a << File.basename(file_name).gsub(''.rb'', '''').camelcase > end > end > render_text a.inspect > end > > > if you run find_controller_names, you''ll get something like > ["Application", "SomeController", "OtherController"] > > hope it helps! > :)hi shai, thanks it is exactly what i want :) meanwhile i find Dir.entries("#{RAILS_ROOT}/app/controllers/") but i get controllers filenames, like admin_controller.rb -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---