# Complex form with ajax

**URL:** <https://www.ruby-forum.com/t/complex-form-with-ajax/147234>\
**Category:** Rails\
**Created:** [August 29, 2008, 5:55pm UTC](https://www.ruby-forum.com/t/complex-form-with-ajax/147234 "2008-08-29T17:55:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSWolasSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@SSWolasSSSS](https://www.ruby-forum.com/u/SSWolasSSSS)\
**Post date:** [August 29, 2008, 5:55pm UTC](https://www.ruby-forum.com/t/complex-form-with-ajax/147234/1 "2008-08-29T17:55:19Z")

</div>

does anyone know why;

= render\_partial ‘comments/form’, :object =\> comment %\>

works and

= link\_to\_function ‘Edit’, nil, :id =\>  
“edit\_comment\_#{comment.id}\_link” do |page|

- page.replace\_html “comment\_#{comment.id}”, :partial =\> ‘comments/  
form’, :object =\> comment

blows up basically because the object is not being fed correctly to  
the partial, so i get a undefined method ticket for nil.

ps: its done in a loop (I.e: i create a link to edit one comment out  
of many) therefore i cant say comment = @comment and let the partial  
sort it.

here is the partial

=== #comments/form

- form\_for [form[:object].ticket, form[:object]] do |f|

thanks in advance

---

<div class="post-metadata">

**Author:** ![SSWolasSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@SSWolasSSSS](https://www.ruby-forum.com/u/SSWolasSSSS)\
**Post date:** [August 29, 2008, 6:39pm UTC](https://www.ruby-forum.com/t/complex-form-with-ajax/147234/2 "2008-08-29T18:39:15Z")

</div>

“Wolas!” wrote:

> = render\_partial ‘comments/form’, :object =\> comment %\>

Use render :partial =\> ‘comments/form’,  
:locals =\> { :object =\> comment }

And :locals =\> is the answer to your other question too.

---

<div class="post-metadata">

**Author:** ![SSWolasSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@SSWolasSSSS](https://www.ruby-forum.com/u/SSWolasSSSS)\
**Post date:** [August 29, 2008, 6:45pm UTC](https://www.ruby-forum.com/t/complex-form-with-ajax/147234/3 "2008-08-29T18:45:41Z")

</div>

genious. thx

Another question:

Can i put a link\_to\_function inside a partial that is rendered by a  
link\_to\_function? (basically an undo link)
