shane
2006-Nov-16 17:56 UTC
How to get a legit ActionController with a nil @session param ... read on
A browser sends a request (/main/index) so ROR creates an instance of
main_controller and invokes the index action on it. main_controller has
registered ``audit" as a before_filter. ``audit" is called first
before
``index". so far so good.
def audit() does this:
// the login_controller handles the login page and
// knows whether or not there''s a valid login by
// inspecting the session param in a certain way
// which it encapsulates.
//
// remember: audit is a method inside main_controller
c = AuthenticationController.new
if c.valid_user == true // if there''s a valid login
. . .
The problem: when c.valid_user (that is LoginController.valid_user via
the `c'' object) attempts to read from it''s @session param it
is nil.
Conclusion: AuthenticationController.new creates a new controller but
its @session param is nil.
Implication: During the normal course of routing action calls, the ROR
framework creates your controller on your behalf via its class method
.new and, at a later time, also sets the session variable for your.
The design goal here is simple: delegation: I can have exactly one
class encapsulate all the authentication stuff. However my design is
broken because of the unexpected problem of not accessing the @session
pram
Comments?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---