Re: Problem with layout for partials

morgler
2009-01-13T13:38:57Z

Hey, thanks for the instructions. Here is the result:

Placing a "debug @my_profile" anywhere ( before the "if"
statement,
inside the first branch of the "if" statement, inside the _private
partial) leads to the correct value (the first_name of the sample
profile is "De"). At the same time placing the debug command inside
the _layout partial gives me a different value (first_name
''Martha''):

show.html.erb:
<%= debug @my_profile.first_name %>     # => "De"
<% if params[:public_view].blank? && @my_profile && me? %>
  <%= debug @my_profile.first_name %>     # => "De"
  <%= render :partial => "profiles/private", :layout =>
''layout'', :object => @my_profile  %>
<% else %>
  <%= render :partial => "profiles/public", :layout =>
''layout'' %>
<% end %>


_private.html.erb:
<% top_bar do %>
  <% @user = @profile.user %>
Über mich: <%= " #{@profile.first_name}
[#{@user.login}]" %> </
h1>
<% end %>

<% left_sidebar do %>
<%= link_to ''<div style="height:
16px;"> <img src="/images/
user_edit.png" style="vertical-align:middle; border:none;"/>
Profil
bearbeiten '', edit_profile_path
(@my_profile), :class=>''button'' %>
<%= link_to ''<div style="height:
16px;"> <img src="/images/
camera_edit.png" style="vertical-align:middle; border:none;">
Fotos
bearbeiten '', profile_photos_path
(@my_profile), :class=>''button'' %>
<% end %>

<%= debug ''_private: '' + @my_profile.first_name %>     #
=> "De"

<%= render :partial => ''profiles/bio'' %>
<%= render :partial => ''profiles/getting_started'' %>
<%= render :partial => ''comments/list'', :locals =>
{:with_form =>
true, :with_wall_to_wall => true} %>
<%= render :partial => ''photos/gallery'', :locals =>
{:mini => true} %>
<%= render :partial => ''friends/list'', :locals =>
{:type => ''friends''}
%>
<%= render :partial => ''profiles/recent_activity'' %>


_layout.html.erb:


<%= debug ''_layout: '' + @my_profile.first_name %>     #
=>
"Martha" !!!!!!!!!!????????




    <%= yield(:top_bar) %>







  <%= render :partial => ''shared/livesidebar'' %>







      	  <%= icon @profile, :big %>


      <%= yield(:left_sidebar) %>




      <%= yield %>





I just don''t get it - it seems weird.

On 13 Jan., 14:13, MaD
<mayer.domi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> maybe try the following:
>
> restructure your code to have your debug-statement inside the if-
> clause (the first branch).
> post the code for the private partial.
> finally, tell us what @my_profile is before the render-command and
> then inside the partial (at the beginning).
> it should really be the same.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com