# Link\_to\_remote and :with

**URL:** <https://www.ruby-forum.com/t/link-to-remote-and-with/131679>\
**Category:** Rails\
**Created:** [March 12, 2008, 1:39pm UTC](https://www.ruby-forum.com/t/link-to-remote-and-with/131679 "2008-03-12T13:39:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [March 12, 2008, 1:39pm UTC](https://www.ruby-forum.com/t/link-to-remote-and-with/131679/1 "2008-03-12T13:39:19Z")

</div>

Hi

```
I have in my view 2 variables
@sd_resolution_id and @sd_ticket

```

How can I pass this t controller…I tried the following but failed  
Please help

```
<%= link_to_remote "Edit Resolution",
                        :update => "create_sd_resolution_ui",
                        :url => { :action =>

```

‘define\_sd\_resolution\_ui’,  
:with =\> “‘sd\_resolution\_id=’+ ‘@sd\_resolution\_id’ + ‘&id=’ +  
escape($(’@sd\_ticket’))”),  
%\>

Thanks in advance  
Sijo

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [March 12, 2008, 1:51pm UTC](https://www.ruby-forum.com/t/link-to-remote-and-with/131679/2 "2008-03-12T13:51:26Z")

</div>

On 12 Mar 2008, at 12:39, Sijo Kg wrote:

> ```
> :update => "create_sd_resolution_ui",
> :url => { :action =>
> 
> ```
> 
> ‘define\_sd\_resolution\_ui’,  
> :with =\> “‘sd\_resolution\_id=’+ ‘@sd\_resolution\_id’ + ‘&id=’ +  
> escape($(’@sd\_ticket’))”),

:with is a javascript fragment, so something like “{sd\_resolution\_id:  
@sd\_resolution\_id, id: escape($(’@sd\_ticket’))}” is probably about  
right.  
in this particular case, can’t you just do

> \<%= link\_to\_remote “Edit Resolution”,  
> :update =\> “create\_sd\_resolution\_ui”,  
> :url =\> { :action =\>  
> ‘define\_sd\_resolution\_ui’, :id =\> @sd\_ticket, :sd\_resolution\_id =\>  
> @sd\_resolution\_id} %\>  
> ?  
> Fred

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [March 12, 2008, 1:56pm UTC](https://www.ruby-forum.com/t/link-to-remote-and-with/131679/3 "2008-03-12T13:56:21Z")

</div>

Sijo Kg wrote:

> How can I pass this t controller…I tried the following but failed  
> Please help
> 
> ```
> <%= link_to_remote "Edit Resolution",
> :update => "create_sd_resolution_ui",
> :url => { :action =>
> 
> ```
> 
> ‘define\_sd\_resolution\_ui’,  
> :with =\> “‘sd\_resolution\_id=’+ ‘@sd\_resolution\_id’ + ‘&id=’ +  
> escape($(‘@sd\_ticket’))”),  
> %\>

:with is for passing in javascript ,not for passing parameters to the  
URL. In all functions which create a URL, you can pass in extra  
parameters in the URL specification part. In your example, you’d want  
something like:

\<%= link\_to\_remote “Edit Resolution”,  
:update =\> “create\_sd\_resolution\_ui”,  
:url =\> {:action =\> :define\_sd\_resolution\_ui,  
:sd\_resolution =\> @sd\_resolution\_id,  
:id =\> @sd\_ticket} %\>

For more information have a look at the examples in the documentation:

[http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper.html#M000958](http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper.html#M000958)

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [March 13, 2008, 9:26am UTC](https://www.ruby-forum.com/t/link-to-remote-and-with/131679/4 "2008-03-13T09:26:28Z")

</div>

Mark B. wrote:

> :with is for passing in javascript ,not for passing parameters to the  
> URL.

Bit misleading there as I wasn’t thinking right at the time. It _is_  
for passing parameters, however it’s mainly useful for passing  
JavaScript values (or DOM values) as parameters.

You _can_ use it for passing Rails values, but it’s a bit ugly compared  
to putting them in the :url hash.

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [March 13, 2008, 5:33am UTC](https://www.ruby-forum.com/t/link-to-remote-and-with/131679/5 "2008-03-13T05:33:05Z")

</div>

Thanks for your replies
