Ruby on Rails Sunday, July 31, 2011

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

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
ApplicationController.

About the methods.

def method1
...
end

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

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

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 = SessionsController.new or
session_helper = SessionsHelper.new?
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment