Scott Seago wrote:
> On Thu, Sep 24, 2009 at 1:56 PM, Scott Seago <sseago(a)redhat.com> wrote:
>
>
>> @@ -1,10 +1,10 @@
>> <div class="header_logo"><%= image_tag "dcloud.png"
%></div>
>>
>> <div class="header_info">
>> - <div id="hi-username">Hi, <%= @user %></div>
>> + <div id="hi-username"><%= "Hi, " +
@current_user.login if defined? @current_user %></div>
>>
>>
> I ran into a problem with the above line (clicking register would blow
> up), because @current_user is sometimes defined when you would think
> it should not be, so the template tries to render nil.login. Changing
> this check to @current_user.login unless @current_user.nil? fixed
> this issue for me. Also, jp may have another idea of where to put
> this, but for now, it would be nice to be able to get to the user page
> (and subsequently the edit page). I was thinking an easy way for now
> would be to have username be a link to account/
>
>
>
nil? will blow up when defined? is false -- so we'd really need "if
defined? @current_user and !(a)current_user.nil?" to handle both cases.
As Bob just reminded me, I was confusing local var behavior with
instance var behavior -- the single .nil? check is sufficient here.
> Same change as above, for check to work properly (can see this by the
> 'add provider' link disappearing), this check should be 'unless
> @current_user.nil? '
>
>
>
Right -- although we need the same double check for defined and nil
Or not.
Scott