# Strange partial

**URL:** <https://discuss.rubyonrails.org/t/strange-partial/51683>\
**Category:** rubyonrails-talk\
**Created:** [May 16, 2010, 5:09pm UTC](https://discuss.rubyonrails.org/t/strange-partial/51683 "2010-05-16T17:09:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [May 16, 2010, 5:09pm UTC](https://discuss.rubyonrails.org/t/strange-partial/51683/1 "2010-05-16T17:09:02Z")

</div>

I am struggling with a strange effect when using two partials This is show.html.erb &nbsp;&nbsp;&nbsp;\<div\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<h2\>posts commented on by \<%= @user.login %\>\</h2\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= render :partial =\> @posts\_commented\_on %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<h2\>Posts submitted by \<%= @user.login %\>\</h2\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= render :partial =\> @posts\_submitted %\> &nbsp;&nbsp;&nbsp;\</div\>

This is the relevant bit of users.html.erb &nbsp;&nbsp;&nbsp;\<div id="useryield"\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= yield %\> &nbsp;&nbsp;&nbsp;\</div\>

This is from users\_controller.rb &nbsp;&nbsp;&nbsp;def show &nbsp;&nbsp;&nbsp;&nbsp;@user = User.find(params[:id]) &nbsp;&nbsp;&nbsp;&nbsp;@posts\_submitted = @user.posts.find(:all, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:limit =\> 6, :order =\> 'posts.id DESC') &nbsp;&nbsp;&nbsp;&nbsp;@posts\_commented\_on = @user.posts\_commented\_on.find(:all, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:limit =\> 2, :order =\> 'comments.id DESC') &nbsp;&nbsp;&nbsp;end

Can anybody tell me where the div, that splits submitted from comments, appears from?

Attachments: [http://www.ruby-forum.com/attachment/4737/Screenshot.png](http://www.ruby-forum.com/attachment/4737/Screenshot.png)

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [May 17, 2010, 9:59am UTC](https://discuss.rubyonrails.org/t/strange-partial/51683/2 "2010-05-17T09:59:17Z")

</div>

> Can anybody tell me where the div, that splits submitted from comments, appears from?

What does the post partial & generated html look like ? Could you have forgotten to close a tag or something like that ?

Fred

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [May 17, 2010, 11:47am UTC](https://discuss.rubyonrails.org/t/strange-partial/51683/3 "2010-05-17T11:47:13Z")

</div>

Frederick Cheung wrote:

> > Can anybody tell me where the div, that splits submitted from comments, appears from?
> 
> What does the post partial & generated html look like ? Could you have forgotten to close a tag or something like that ?
> 
> Fred

Hope this helps

I've attached the generated html. The partials are defined in this extract from user\_controller.rb def show &nbsp;&nbsp;&nbsp;&nbsp;@user = User.find(params[:id]) &nbsp;&nbsp;&nbsp;&nbsp;@posts\_submitted = @user.posts.find(:all, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:limit =\> 6, :order =\> 'posts.id DESC') &nbsp;&nbsp;&nbsp;&nbsp;@posts\_commented\_on = @user.posts\_commented\_on.find(:all, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:limit =\> 2, :order =\> 'comments.id DESC') &nbsp;&nbsp;end How can it create a div in the middle of a find operation?

Attachments: [http://www.ruby-forum.com/attachment/4739/index.html.erb](http://www.ruby-forum.com/attachment/4739/index.html.erb)

---

<div class="post-metadata">

**Author:** ![Rick\_DeNatale](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Rick\_DeNatale](https://discuss.rubyonrails.org/u/Rick_DeNatale)\
**Post date:** [May 17, 2010, 12:27pm UTC](https://discuss.rubyonrails.org/t/strange-partial/51683/4 "2010-05-17T12:27:44Z")

</div>

Let's look at the first post from that

\<h2\>posts commented on by gleb\</h2\> \<div class="post" id="post\_6"\> &nbsp;&nbsp;\<h3\>\<a href="/posts/6"\>Nathan's tail\</a\>\</h3\> &nbsp;&nbsp;\<p class="content"\> &nbsp;&nbsp;&nbsp;&nbsp;Hi, I am a dog. Woof,woof &nbsp;&nbsp;\</p\> &nbsp;&nbsp;\<p class="new"\>

&nbsp;&nbsp;&nbsp;&nbsp;\<em\>Please log in to place a comment.\</em\> &nbsp;&nbsp;&nbsp;&nbsp;\<a href="/session/new"\>Login\</a\>

&nbsp;&nbsp;\</p\> \</div\> \<p\> &nbsp;&nbsp;Submitted by: \<a href="/users/4"\>rover\</a\> \</p\> \</div\>

You have one \<div\> tag and two \</div\> tags, which isn't balanced. This appears to be consistent for each post.

I would guess you want that last closing div tag and not the one 4 lines above.

I suspect that this is in \_post.html.erb

HTH

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [May 17, 2010, 4:31pm UTC](https://discuss.rubyonrails.org/t/strange-partial/51683/5 "2010-05-17T16:31:53Z")

</div>

You were right, stupid of me. Thanks
