Unlike PHP (Codeigniter), in Ruby require
and include
are very different in behaviour.
require
loads a given path (somewhat like PHP) while include
is usually used to include a Module
in a Class
.
require
is a method from Kernel
while include
acts more like an object of class Class
. Try -
Kernel.respond_to? :require
include.is_a? Class
Before jumping on Rails, I suggest you to read on Ruby. I suggest this book and http://en.wikibooks.org/wiki/Ruby_programming_language.
For Ruby on Rails, I recommend -
- http://guides.rubyonrails.org/
- http://api.rubyonrails.org/
For 2nd question,
I guess, initialising plugins is part of Rails' initialisation process, so it probably can not be selective (but I'm not sure). See http://ryanbigg.com/guides/initialization.html for more information.
The most easiest way to avoid a plugin from being initialised is to put it in some path which is not in Rails' (auto)load_paths
, say vendor/extensions
and require
them in controllers when needed using
require "vendor/extensions/example-plugin/lib/example-plugin"
However, I recommend against it and suggest to wait until your plugin count reaches 1000/10. :)