I like the feature to have layouts even for partials now. But I have a
problem related to this topic:
My controller sets the variable @my_profile somewhere before
rendering. In the view I have the following code:
<%= debug @my_profile %>
<% if me? %>
<%= render :partial => "profiles/private", :layout => 'layout' %>
<% else %>
<%= render :partial => "profiles/public", :layout => 'layout' %>
<% end %>
The "debug" outputs the correct value. The two actual partials are not
important, but the _layout partial is where the trouble begins. In
case this "if" renders the second option (the _public partial), I can
also trace the @my_profile in the _layout partial - everything is
fine. However, if the above statement branches to the first option
(_private partial), tracing the @my_profile variable in the _layout
partial gives me a DIFFERENT value (actually another valid profile,
but not the one it is supposed to be)! I have no idea, how @my_profile
is set to a different value?! Is it possible for a controller action
to happen in the middle of rendering a view? I can't imagine that,
since a partial has no action associate with it (and neither has a
partial layout). Does anyone have an idea how this value could become
set differently during the parital rendering process?
I would appreciate any kind of help! Thanks.