Ruby on Rails Sunday, July 31, 2011

your implementation makes more sense to me than the example of the

In your code you write:

def get_user_from_cookie
@current_user || begin <------- what is the begin ? or is that line
code a typo?

Pffff... it took me back to basics!
According to the book with attr_accessor we create virtual attributes
(when we dont want to save something in the database).
But it uses them inside a model class (user class) so it's been called
as self.password (when attr_accessor :password)
I didn't see it outside a model class so im having problems
understanding and getting used to getter and setter outside a model
class since its the same thing.
Not to mention the "self" outside a model class... very strange.

So the logic behind Helpers and the module is that when we're not
using a model (px for Sessions) and since the code needed for sign-
in / sign-out doesn't involve an action-view relationship like with
Controllers -it's just methods and programming-
we use the SessionsHelper with modules and not the

About the methods.

def method1

is one type of method which doesn't require an argument

def method2(string1, string2, string3...)

is the other type which requires input.

So you mean that since we dont write "self" Rails infers:

self.method1 and self.method2(string1, string2, string3...) when we
call them?

with self being the session_controller = or
session_helper =
or is it any other object?

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
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment