Frederick Cheung wrote in post #1013993: > On Jul 31, 1:03pm, 7stud -- <[email protected]> wrote: >> It follows that the line: >> >> <%= current_user.name %> >> >> actually does this: >> >> <%= current_user().name %> > > Punctuation is usually optional in ruby when this doesn't introduce > ambiguities. > >> >> What I found to be a new concept in this section of the book is that we >> can >> call methods in the view that are inherited by the >> controller: > > You can't. The reason why the methods in SessionsHelper can be used in > the view is that (by default) all the helpers in app/helpers are > included in views. > When you add the method directly to the controller then this no longer > holds and so the view can't find the method
Ahh. Okay. What do you think about this: > def current_user > @current_user ||= user_from_remember_token > end > > I see two problems with that function. First off, that is a getter > function, yet it can set the @current_user variable. Getter functions > should not set instance variables. Secondly, the function directly sets > the @current_user variable instead of calling the current_user= setter > function. -- Posted via http://www.ruby-forum.com/. -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

