# Issue rendering past a certain point with partials

**URL:** <https://www.ruby-forum.com/t/issue-rendering-past-a-certain-point-with-partials/226041>\
**Category:** Rails\
**Created:** [July 18, 2009, 12:53am UTC](https://www.ruby-forum.com/t/issue-rendering-past-a-certain-point-with-partials/226041 "2009-07-18T00:53:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@ahad](https://www.ruby-forum.com/u/ahad)\
**Post date:** [July 18, 2009, 12:53am UTC](https://www.ruby-forum.com/t/issue-rendering-past-a-certain-point-with-partials/226041/1 "2009-07-18T00:53:11Z")

</div>

Hello all,

I posted this on the railsforum website as well, and haven’t received  
any response, so I figured I’d try and get a bit more exposure by seeing  
if anyone here and on the mailing list would be able to assist: I’m  
having an extremely strange issue with respect to partials.

I have an empty fieldset, with an id of “claim” that in the initial  
view, I have set to:

1. 
2. 

```
<%= render :partial => 'claim', :layout => false %>

```

3. 

In the render file, I have a legend followed by 5 divs setting up a  
4-field form (1 select, 3 text inputs) and a button, which is  
conditionally either an “Add” or an “Edit”, that I’m using Prototype to  
utilize AJAX submissions of the record being added or edited into the  
database.

Here’s the top of the partial:

1. Claims
2. 
3. 
4. \<% remote\_form\_for @full\_quote\_ho\_claim, :url =\>  
‘Javascript.void(0)’, :html =\> {:id =\> ‘ClaimForm’} do |form| %\>
5. 

6. \<%= form.label :description, ‘Description:’ %\>
7. \<%= form.text\_field :description, :size =\> 50, :maxlength =\> 50  
%\>
8. 
9. 

10. \<%= form.label :cause\_of\_loss, ‘Cause of Loss:’ %\>
11. \<%= form.select :cause\_of\_loss, @causesOfLoss %\>
12. 
13. 

14. \<%= form.label :date\_of\_loss, ‘Date of Loss:’ %\>
15. \<%= form.text\_field :date\_of\_loss, :size =\> 10, :maxlength =\> 10  
%\>
16. 
17. 

18. \<%= form.label :amount\_of\_loss, ‘Amount of Loss:’ %\>
19. \<%= form.text\_field :amount\_of\_loss, :size =\> 15, :maxlength =\>  
15 %\>
20. 
21. 

22. \<% if @modify == false %\>
23. \<%= submit\_to\_remote ‘add\_claim\_btn’, ‘Add Claim’, :url =\>  
{:controller =\> :full\_quote\_ho\_locs, :action =\> :add\_claim, :id =\>  
@full\_quote\_ho\_loc.id, :full\_quote\_ho\_model\_id =\>  
@full\_quote\_ho\_model.id}, :update =\> {:success =\> ‘claim’, :failure =\>  
‘notice’} %\>
24. \<% else %\>
25. \<%= submit\_to\_remote ‘update\_claim\_btn’, ‘Update Claim’, :url =\>  
{:controller =\> :full\_quote\_ho\_locs, :action =\> :update\_claim, :id =\>  
@full\_quote\_ho\_loc.id, :full\_quote\_ho\_model\_id =\>  
@full\_quote\_ho\_model.id, :full\_quote\_ho\_claim\_id =\>  
@full\_quote\_ho\_claim.id}, :update =\> {:success =\> ‘claim’, :failure =\>  
‘notice’} %\>
26. \<% end %\>
27. 
28. \<% end %\>

This portion of the code always renders fine. Now, I’m trying to go back  
and display a listing directly underneath the form allowing a user to  
see all claims they have just added, edited, or removed. This portion  
shows up perfectly the first time, but doesn’t show up after I add a  
claim, edit a claim, or remove a claim. It doesn’t make sense to me,  
since the whole thing (top with the form, and bottom with the view) are  
all in the same partial, \_claims.html.erb.

Here’s the bottom of the partial:

1. 
2. 

3. \<% if !@full\_quote\_ho\_claims.blank? %\>
4. 
5. 
6. 

```
<th>Description:</th>

```

7. 

```
<th>Cause of Loss:</th>

```

8. 

```
<th>Date of Loss:</th>

```

9. 

```
<th>Amount of Loss:</th>

```

10. 

```
<th>Modify</th>

```

11. 

```
<th>Remove</th>

```

12. 
13. \<% @full\_quote\_ho\_claims.each do |claim| %\>
14. \<% remote\_form\_for claim, :url =\> ‘Javascript.void(0)’ do |form|  
%\>
15. 
16. 

```
<td><%= claim.description %></td>

```

17. 

```
<td><%= claim.cause_of_loss %></td>

```

18. 

```
<td><%= claim.date_of_loss %></td>

```

19. 

```
<td><%= claim.amount_of_loss %></td>

```

20. 

```
<td><%= submit_to_remote 'edit_claim_btn', 'Edit Claim', :url

```

=\> {:controller =\> :full\_quote\_ho\_locs, :action =\> :edit\_claim, :id =\>  
@full\_quote\_ho\_loc.id, :full\_quote\_ho\_model\_id =\>  
@full\_quote\_ho\_model.id, :full\_quote\_ho\_claim\_id =\> claim.id}, :update  
=\> {:success =\> ‘claim’, :failure =\> ‘notice’} %\>  
21.

  
22.   
23. \<% end %\>  
24. \<% end %\>  
25. 

|
| |
| \<%= submit\_to\_remote ‘remove\_claim\_btn’, ‘Remove Claim’,  
:url =\> {:controller =\> :full\_quote\_ho\_locs, :action =\> :remove\_claim,  
:id =\> @full\_quote\_ho\_loc.id, :full\_quote\_ho\_model\_id =\>  
@full\_quote\_ho\_model.id, :full\_quote\_ho\_claim\_id =\> claim.id}, :update  
=\> {:success =\> ‘claim’, :failure =\> ‘notice’}, :html =\> {:style =\>  
“background: red”}, :confirm =\> ‘Are you sure you wish to remove this  
claim?’ %\> |

  
26. \<% end %\>  
27. 

The controller code is relatively the same for all actions, and I’m  
experiencing the problem with all of them once I submit an AJAX request,  
no matter which one it is. The thing is, the partial is rendered with  
the same state in the initial view as it is after any AJAX requests.

And the weirdest part is, if I move the \<% end %\> tag from the end of  
the top half of the partial to the end of the bottom half of the partial  
(extending the remote\_form\_for to the end of the partial instead of just  
to the form part) then the topmost record does show up. Does anyone have  
any idea what’s going on?

Just for reference, here’s the controller code:

  1. class FullQuoteHoLocsController \< ApplicationController
  2. before\_filter :setupFullQuoteHoModel
  3. layout “fqho”
  4. 
  5. def setupFullQuoteHoModel
  6. 

```
@full_quote_ho_model =

```

FullQuoteHoModel.find(params[:full\_quote\_ho\_model\_id])  
7. @full\_quote\_ho\_loc = FullQuoteHoLoc.find(params[:id])  
8. end  
9.  
10. def variables\_from\_params(modify)  
11. if params[:full\_quote\_ho\_claim\_id] != nil  
12. @full\_quote\_ho\_claim =  
FullQuoteHoClaim.find(params[:full\_quote\_ho\_claim\_id])  
13. else  
14. @full\_quote\_ho\_claim = FullQuoteHoClaim.new  
15. end  
16. @modify = modify  
17.  
18. refresh\_claims()  
19. end  
20.  
21. def refresh\_claims  
22. @full\_quote\_ho\_claims = FullQuoteHoClaim.find(:all, :order =\>  
:id, :conditions =\> {:full\_quote\_ho\_loc\_id =\> @full\_quote\_ho\_loc.id})  
23. if @full\_quote\_ho\_claims.size \> 0  
24. flash[:notice] = nil  
25. else  
26. @full\_quote\_ho\_claims = nil  
27. flash[:notice] = ‘No claims exist for this quote.’  
28. end  
29. return @full\_quote\_ho\_claims  
30. end  
31.  
32. def add\_claim  
33. controllerDropDownsSetup()  
34. variables\_from\_params(false)  
35.  
36. @claim = FullQuoteHoClaim.create({  
37. :description =\> params[:full\_quote\_ho\_claim][:description],  
38. :cause\_of\_loss =\>  
params[:full\_quote\_ho\_claim][:cause\_of\_loss],  
39. :date\_of\_loss =\>  
params[:full\_quote\_ho\_claim][:date\_of\_loss],  
40. :amount\_of\_loss =\>  
params[:full\_quote\_ho\_claim][:amount\_of\_loss]  
41. })  
42. @full\_quote\_ho\_loc.full\_quote\_ho\_claims \<\< @claim  
43.  
44. render :partial =\> ‘claim’, :layout =\> false  
45. end  
46.  
47. def edit\_claim  
48. controllerDropDownsSetup()  
49. variables\_from\_params(true)  
50.  
51. @full\_quote\_ho\_claims = refresh\_claims()  
52. render :partial =\> ‘claim’, :layout =\> false  
53. end  
54.  
55. def update\_claim  
56. controllerDropDownsSetup()  
57. variables\_from\_params(false)  
58.  
59.  
@full\_quote\_ho\_claim.update\_attributes(params[:full\_quote\_ho\_claim])  
60. @full\_quote\_ho\_claim = FullQuoteHoClaim.new  
61.  
62. render :partial =\> ‘claim’, :layout =\> true  
63. end  
64.  
65. def remove\_claim  
66. controllerDropDownsSetup()  
67. variables\_from\_params()  
68.  
69.  
@full\_quote\_ho\_loc.full\_quote\_ho\_claims.find(@full\_quote\_ho\_claim).destroy  
70. @full\_quote\_ho\_claim = FullQuoteHoClaim.new  
71.  
72. render :partial =\> ‘claim’, :layout =\> false  
73. end  
74.  
75. …  
76.  
77. # GET /full\_quote\_ho\_locs/1/edit  
78. def edit  
79. controllerDropDownsSetup()  
80. variables\_from\_params(false)  
81. end

As you can see, the edit is initialized the same way that all the others  
are. When I first go to the edit view, the form and display show up  
perfectly, with all records listed. The partial is rendered completely.  
However, when I fire any of the AJAX buttons, the partial is only  
half-way rendered, showing the form, but not the listing of all records.  
Does anyone know why this could be the case?

Thanks in advance, and for taking the time to read,  
Ahad.

---

<div class="post-metadata">

**Author:** ![ahad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@ahad](https://www.ruby-forum.com/u/ahad)\
**Post date:** [July 19, 2009, 10:16am UTC](https://www.ruby-forum.com/t/issue-rendering-past-a-certain-point-with-partials/226041/2 "2009-07-19T10:16:16Z")

</div>

Okay, things are working now. Not sure what I really did to make things  
work, but it was primarily alteration of the partial. I’ll compare the  
two later on and post back the differences.
