Hi folks! Today I faced a very strange problem. I have two controllers: ManageController and FooController. FooController derives from ApplicationController: class FooController < ApplicationController end And ManageController derives from FooController: require_dependency ''foo'' class ManageController < FooController def index ... end end Now if I call the action index on ManageController first the first time everything works as expected. On the second attempt, however, it breaks for Rails no longer knows about FooController? Even with " require ''foo'' " it only works for the first request. Is this a bug or a feature? :-) Yours, Lars -- "Stil ist die Fähigkeit, komplizierte Dinge einfach zu sagen - nicht umgekehrt." -- Cocteau, Jean
I found a workaround: I renamed my file foo.rb to foo_controller.rb. Afterwards it worked as expected. But still I wonder why it is not possible to call it "foo.rb" like "application.rb"? Yours, Lars Am 06.01.2005 um 15:57 schrieb Lars Hoss:> Hi folks! > > Today I faced a very strange problem. I have two controllers: > ManageController and FooController. FooController derives from > ApplicationController: > > class FooController < ApplicationController > end > > And ManageController derives from FooController: > > require_dependency ''foo'' > > class ManageController < FooController > def index > ... > end > end > > Now if I call the action index on ManageController first the first > time everything works as expected. On the second attempt, however, it > breaks for Rails no longer knows about FooController? Even with " > require ''foo'' " it only works for the first request. > Is this a bug or a feature? :-) > > Yours, > Lars > > -- > "Stil ist die Fähigkeit, komplizierte Dinge einfach zu sagen - nicht > umgekehrt." -- Cocteau, Jean > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >-- "Stil ist die Fähigkeit, komplizierte Dinge einfach zu sagen - nicht umgekehrt." -- Cocteau, Jean
Hi Lars, Lars Hoss schrieb:> I renamed my file foo.rb to foo_controller.rb. Afterwards it worked as > expected. But still I wonder why it is not possible to call it "foo.rb" > like "application.rb"?This is simply convention. application.rb is a special controller just happening to be in the same dir as the other controllers. I personally would find it better if these special files would be one directory up (in app) to signal their special meaning. -- Sascha Ebach
> I renamed my file foo.rb to foo_controller.rb. Afterwards it worked as > expected. But still I wonder why it is not possible to call it > "foo.rb" like "application.rb"?This is an undocumented naming convention. The controllers and models must have the lowercased and underscored filename of their class name. So FooController must reside in foo_controller.rb. Otherwise the automatic reloading won''t pick it up. application.rb is special in the sense that its part of the framework and accounted for through other means. -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://macromates.com/ -- TextMate: Code and markup editor (OS X) http://www.loudthinking.com/ -- Broadcasting Brain
Hi David! Am 06.01.2005 um 16:28 schrieb David Heinemeier Hansson:>> I renamed my file foo.rb to foo_controller.rb. Afterwards it worked >> as expected. But still I wonder why it is not possible to call it >> "foo.rb" like "application.rb"? > > This is an undocumented naming convention. The controllers and models > must have the lowercased and underscored filename of their class name. > So FooController must reside in foo_controller.rb. Otherwise the > automatic reloading won''t pick it up.Ok, I see. Perhaps a note in ActionController::Base would do it? Something like "your controller file _MUST_ end with _controller.rb or it will not work" :-)> application.rb is special in the sense that its part of the framework > and accounted for through other means.I agree with Sascha. Is application.rb well placed below controllers? Yours, Lars> -- > David Heinemeier Hansson, > http://www.basecamphq.com/ -- Web-based Project Management > http://www.rubyonrails.org/ -- Web-application framework for Ruby > http://macromates.com/ -- TextMate: Code and markup editor (OS X) > http://www.loudthinking.com/ -- Broadcasting Brain > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >-- "Stil ist die Fähigkeit, komplizierte Dinge einfach zu sagen - nicht umgekehrt." -- Cocteau, Jean