Michal Burak wrote:

> 
> -------- home/_current_user.pl.html.erb  :   --------
> <% if current_user %>
>   NOT NIL
> <% else %>
>   NIL
> <% end %>
> 
> -------- home/_user_box.pl.html.erb  :   --------
> <% if current_user %>
>   NOT NIL
> <% else %>
>   NIL
> <% end %>
> 
> -------- layouts/layout.html.erb  :   --------
> <%= render :partial => '/home/current_user' -%>
> <%= render :partial => '/home/user_box' %>
> 

> 
> Why is that so? Why one time it is nil and the other time it is not nil?
> 
> Any help appreciated.
> 
> Regards.

It has to do with the name of the partial, Rails does some magic by 
looking at the name of the partial and then making a local variable 
(with the same name as the partial) accessible to that partial.

i.e.  a partial entitled "_current_user"  will have current_user as a 
local whereas a partial entitled "_user_box" will have user_box as a 
local.

This was new functionality introduced with rails 2 I believe..

Don't forget that the render() can have :object and :locals passed into 
it..

hth

ilan



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

Reply via email to