# Link to remote + update

**URL:** <https://www.ruby-forum.com/t/link-to-remote-update/150023>\
**Category:** Rails\
**Created:** [October 2, 2008, 4:22pm UTC](https://www.ruby-forum.com/t/link-to-remote-update/150023 "2008-10-02T16:22:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![da991319](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@da991319](https://www.ruby-forum.com/u/da991319)\
**Post date:** [October 2, 2008, 4:22pm UTC](https://www.ruby-forum.com/t/link-to-remote-update/150023/1 "2008-10-02T16:22:33Z")

</div>

Hi,

i need to post a form using AJAX so that I can update and save my  
object:

form:  
\<% form\_for(@sample,:html =\> {:id =\> “analyses\_list”}) do %\>  
**Analyses:**

 \<%= render :partial =\> 'parameters/parameter\_name', :collection =\> @parameters %\> 
\<% end %\>

if I am using link\_to\_function in order to post the form, everything  
is alright except that it’s not an AJAX request, but at least the  
action update is called:

link:  
\<%= link\_to\_function(“Remove an analysis from sample # #{@sample.id}”,  
“if (confirm(‘Are you sure you want to remove those analyses?’)) $  
(‘analyses\_list’).submit();”) %\>

I try using link to remote, but i have a problem with the url  
parameter, i cant get the link to send the request to the update  
action.

\<%= link\_to\_remote “Remove analyses from sample” ,{:url =\> {:action =\>  
‘update’, :id =\>@sample}}, {:confirmation =\> true,:submit =\>  
‘analyses\_list’} %\>

i also tried  
{:url =\> sample\_url(@sample), :method =\> :put}

---

<div class="post-metadata">

**Author:** ![da991319](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@da991319](https://www.ruby-forum.com/u/da991319)\
**Post date:** [October 3, 2008, 10:02am UTC](https://www.ruby-forum.com/t/link-to-remote-update/150023/2 "2008-10-03T10:02:28Z")

</div>

i already try with

form:

\<% remote\_form\_for(@sample,:html =\> {:id =\> “analyses\_list”}) do %\>  
**Analyses:**

 \<%= render :partial =\> 'parameters/parameter\_name', :collection =\> @parameters %\> 
\<% end %\>

link:

\<%= link\_to\_function(“Remove an analysis from sample #  
#removed\_email\_address@domain.invalid}”,  
“if (confirm(‘Are you sure you want to remove those analyses?’)) $  
(‘analyses\_list’).submit();”) %\>

but if the update action is correctly done, my update.js.rjs is not  
called and i get an error

Missing template samples/update.html.erb in view path F:/Programmation/  
ROR/LIMS/app/views

which mean that update is dealing with an regular http request, not  
AJAX one. As my link is not in the form itself i assume that is the  
link that need to perform the AJAX request, not the form.

On Oct 2, 8:35 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![da991319](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@da991319](https://www.ruby-forum.com/u/da991319)\
**Post date:** [October 6, 2008, 4:42pm UTC](https://www.ruby-forum.com/t/link-to-remote-update/150023/3 "2008-10-06T16:42:29Z")

</div>

i finally mange to get it works it was quiet obvious in fact:  
link:

\<%= link\_to\_remote “Remove analyses from sample # #{@sample.id}” ,:url  
=\> {:action =\> ‘update’, :id=\> @sample}, :confirmation =\> true,:submit  
=\> ‘analyses\_list’ %\>

---

<div class="post-metadata">

**Author:** ![da991319](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@da991319](https://www.ruby-forum.com/u/da991319)\
**Post date:** [October 6, 2008, 4:46pm UTC](https://www.ruby-forum.com/t/link-to-remote-update/150023/4 "2008-10-06T16:46:36Z")

</div>

edit:

except that i don’t have a confirmation pop up. ;-(
