I am newb. I feel confused about how params works.
I understand @params is an attribute of CLASS, but what is params? A
named parameter? Because I thought instance attributes always begin
with "@”, so params/request/flash/etc looks like a local variable.
thanks in advance
Xiahong
On Jun 21, 8:04 pm, Xiahong G. [email protected] wrote:
I am newb. I feel confused about how params works.
I understand @params is an attribute of CLASS, but what is params? A
named parameter? Because I thought instance attributes always begin
with "@”, so params/request/flash/etc looks like a local variable.
thanks in advance
Xiahong
params, request, etc are just instance methods that return hashes.
for example, flash’es implementation (action_controller/flash.rb):
def flash #:doc:
unless defined? @_flash
@_flash = session["flash"] ||= FlashHash.new
@_flash.sweep
end
@_flash
end
flash is the instance method of class ActionController::Flash. but our
application controller is inherited from ActionController::Base, why can
we
use flash in our application controller ?
to be more concrete, i guess the code has the following form:
Class ActionController{
Class Flash
def flash
end
…
end
Class Base
# can we call instance methods of Flash here??
end
end
thanks,
xiahong
2009/6/21 pharrington [email protected]