David Johnson
2007-Jul-06 00:12 UTC
Problem with discovering available controllers through reflection
This code works under webrick to load and identify every controller in a rails
app. However, it fails under mongrel. Instead it only identifies the
controller that actually called the method.
Does anyone understand why?
Thanks in advance,
David Johnson
NW Arkansas
------------------------------------------------------------------
code snip:
def MyModel.synchronize_with_controllers
# Load all the controller files
Find.find( RAILS_ROOT + ''/app/controllers'' ) do
|file_name|
if /_controller.rb$/ =~ file_name
if (@@debuglevel >= 4)
p "Loading "+file_name
end
begin
load file_name
rescue
logger.error("Unable to load file #{file_name}")
end;
end
end
all_controllers = ObjectSpace.subclasses_of( ApplicationController )
if (@@debuglevel >= 4)
p ''----------------------------''
p "all_controllers:"
p all_controllers;
p ''----------------------------''
end
------------------------------------------------------------------
Log from Mongrel (what''s up?):
"Loading script/../config/../app/controllers/first_controller.rb"
"Loading script/../config/../app/controllers/second_controller.rb"
"Loading script/../config/../app/controllers/third_controller.rb"
"Loading script/../config/../app/controllers/fourth_controller.rb"
"Loading script/../config/../app/controllers/this_controller.rb"
"Loading script/../config/../app/controllers/fifth_controller.rb"
"Loading script/../config/../app/controllers/sixth_controller.rb"
"Loading script/../config/../app/controllers/seventh_controller.rb"
"Loading script/../config/../app/controllers/eighth_controller.rb"
"----------------------------"
"all_controllers:"
[ThisController]
"----------------------------"
------------------------------------------------------------------
Log from Webrick (expected behavior):
"Loading script/../config/../app/controllers/first_controller.rb"
"Loading script/../config/../app/controllers/second_controller.rb"
"Loading script/../config/../app/controllers/third_controller.rb"
"Loading script/../config/../app/controllers/fourth_controller.rb"
"Loading script/../config/../app/controllers/this_controller.rb"
"Loading script/../config/../app/controllers/fifth_controller.rb"
"Loading script/../config/../app/controllers/sixth_controller.rb"
"Loading script/../config/../app/controllers/seventh_controller.rb"
"Loading script/../config/../app/controllers/eighth_controller.rb"
"----------------------------"
"all_controllers:"
[FirstController,SecondController,ThirdController,FourthController,ThisController,FifthController,SixthController,SeventhController,EighthController]
"----------------------------"
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2007-Jul-06 00:47 UTC
Re: Problem with discovering available controllers through reflection
Hi -- On Thu, 5 Jul 2007, David Johnson wrote:> > This code works under webrick to load and identify every controller in a rails > app. However, it fails under mongrel. Instead it only identifies the > controller that actually called the method.I''m afraid I can only give you the unhelpful report that it worked OK under Mongrel when I ran it. David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.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 -~----------~----~----~----~------~----~------~--~---
johnson_d-j9pdmedNgrk@public.gmane.org
2007-Jul-06 03:03 UTC
Re: Problem with discovering available controllers through reflection
I''m running mongrel 1.0.1, ruby 1.8.4, rails 1.2.3 on gentoo and ubuntu (feisty) linux. What platform are you running on? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2007-Jul-06 12:57 UTC
Re: Problem with discovering available controllers through reflection
Hi -- On Thu, 5 Jul 2007, johnson_d-j9pdmedNgrk@public.gmane.org wrote:> > I''m running mongrel 1.0.1, ruby 1.8.4, rails 1.2.3 on gentoo and > ubuntu (feisty) linux. > > What platform are you running on?Mac Tiger, Ruby 1.8.6, Rails 1.2.3, Mongrel 1.0.1. David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.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 -~----------~----~----~----~------~----~------~--~---
gene.tani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-06 13:46 UTC
Re: Problem with discovering available controllers through reflection
On Jul 5, 5:12 pm, David Johnson <johnso...-j9pdmedNgrk@public.gmane.org> wrote:> This code works under webrick to load and identify every controller in a rails > app. However, it fails under mongrel. Instead it only identifies the > controller that actually called the method. > > Does anyone understand why? >how about Dir.glob e.g. http://destiney.com/blog/rubyonrails-model-controller-lists --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
johnson_d-j9pdmedNgrk@public.gmane.org
2007-Jul-07 07:47 UTC
Re: Problem with discovering available controllers through reflection
> > Mac Tiger, Ruby 1.8.6, Rails 1.2.3, Mongrel 1.0.1. >I bet an update to Ruby 1.8.6 is in order. Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---