From: Gavin Kistner Date: 2006-10-19T08:03:56+09:00 Subject: Re: Partial Resolution? From: gsm.beamon@gmail.com [mailto:gsm.beamon@gmail.com] > But there's still no: include ActionController::Layout::ClassMethods. Nope. But in action_controller/layout.rb there is: module ActionController #:nodoc: module Layout #:nodoc: def self.included(base) base.extend(ClassMethods) [...snip...] end end end > HOW DO YOU KNOW, BOTTOM LINE, AFTER ALL THE VARIOUS FILES ARE > CONSIDERED, WHAT A CLASS DOES? A few choices: 1) At runtime, ask it: C:\...\site>ruby script\console Loading development environment. >> puts ActionController::Base.methods.sort < <= <=> == === =~ > >= __id__ [...snip...] layout layout_conditions load [...snip...] 2) Trust the author(s) of the code to write sufficient documentation that explains to you all you need to know. 3) Read the source code. I realize that none of these are ideal for huge projects like rails. I'm not claiming that they are, I'm just laying out some options. > I still don't know how ApplicationController::Base can call > layout(). I still can't understand why it's not in the doc as common > sense demands. Hopefully you now understand why it can call layout. To recap: ActionController::Base.class_eval do include ActionController::Layout end ... module ActionController::Layout def self.included(base) base.extend(ClassMethods) end end Why it's not in the documentation is because: 1) RDoc was not smart enough to figure out that the end result of all those runtime calls would always include ClassMethods methods as methods of the ActionController::Base class. and 2) Nobody writing the documentation for rails noticed this omission and wrote additional explanatory code letting you know that all the methods from ActionController::Layout::ClassMethods are available inside ActionController::Base.