i am struggling a bit with all of them .. could someone be so nice a describe me the exact differences, pros & cons of all of them ... thx a lot!
on 28.11.2007 23:16
on 29.11.2007 12:52
I wrote about include/require in my blog a while back ... http://francis.blog-city.com/extendingmixin_ruby_classes_with_modules.htm I've never used require_dependency ... HTH
on 29.11.2007 13:07
On Nov 29, 2007, at 12:52 PM, ghoti wrote: > I wrote about include/require in my blog a while back ... > > http://francis.blog-city.com/extendingmixin_ruby_classes_with_modules.htm > > I've never used require_dependency ... That's internal Rails stuff. More or less it means "load this library and monitor the constants it defines". If your file follows Rails conventions it is picked up automatically and class reloading works out of the box. If the file does not follow them, for example "application.rb" would be called "application_controller.rb" if it did, you can still load it and get the benefits of automatic class reloading via require_dependency. I don't know whether is meant for public consumption though, since it is not documented. Just follow Rails file naming conventions and let Dependencies do its job. -- fxn
on 29.11.2007 16:27
On Nov 29, 2007, at 5:52 AM, ghoti wrote: > > I wrote about include/require in my blog a while back ... > > http://francis.blog-city.com/extendingmixin_ruby_classes_with_modules.htm Nice simple explanation. Thanks, By the way, and totally off-topic, to anybody wondering about the name "ghoti," if I recall correctly, it's an alternate "spelling" of the word fish, using the gh from laugh, the o from women, an the ti from nation. It was constructed by somebody (I don't remember who) a long long time ago complaining about spelling in English. I hadn't thought of it in many years until I saw it here. :-)
on 29.11.2007 17:24
thanks for the detailed explanation ... could you briefly outline the "naming conventions"
on 29.11.2007 17:57
On Nov 29, 2007, at 5:24 PM, Michal Gabrukiewicz wrote: > thanks for the detailed explanation ... > could you briefly outline the "naming conventions" Sure, take the fully-qualified name of the class you want Rails to autoload and run this: $ script/console Loading development environment. >> "FooBar::Woo".underscore + '.rb' => "foo_bar/woo.rb" That says that if the class FooBar::Woo is defined in a file named "foo_bar/woo.rb" living inmediately below some standard application directory like app/controllers Rails will find the file and load it for you automatically. For example, if you define the User class in the file user.rb under app/models you don't need to require 'user'. Note you would in regular Ruby. -- fxn
on 29.11.2007 19:16
i see... but this applies only to the contents within the "app" directory doesnt it?
on 29.11.2007 19:23
On Nov 29, 2007, at 7:16 PM, Michal Gabrukiewicz wrote: > i see... but this applies only to the contents within the "app" > directory doesnt it? Not really. It applies to the contents listed in Dependencies.load_path, which in addition to app subdirs include lib and a few others. Check it out in the console. That list may be further customised via config.load_paths in environment.rb. -- fxn
on 29.11.2007 19:25
thanks.. great help!! will try to use that knowledge....