# Pass parameters to controller from link\_to\_remote

**URL:** <https://www.ruby-forum.com/t/pass-parameters-to-controller-from-link-to-remote/69574>\
**Category:** Rails\
**Created:** [September 21, 2006, 10:49pm UTC](https://www.ruby-forum.com/t/pass-parameters-to-controller-from-link-to-remote/69574 "2006-09-21T22:49:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cliffeh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/df705f/32.png) [@cliffeh](https://www.ruby-forum.com/u/cliffeh)\
**Post date:** [September 21, 2006, 10:49pm UTC](https://www.ruby-forum.com/t/pass-parameters-to-controller-from-link-to-remote/69574/1 "2006-09-21T22:49:27Z")

</div>

I have an e-mail-type app where users will see either a list of message  
headers, or a single message. From either view, they need to be able to  
delete a message.

When delete is called from the list view, I use :loading =\>  
visual\_effect(:fade, ‘my\_id’), then in the controller the record is  
actually deleted and nothing needs to be rendered back. This works  
fine.

However, if delete is called from the expanded message view, I need the  
controller to render the list of messages again.

Any suggestions on how I can either tell from the controller where a  
request came from, or else pass something with the link\_to\_remote? Is  
there a :locals parameter? It doesn’t make sense to have 2 methods in  
the controller - say a delete\_from\_list and delete\_from\_message.

Thanks,  
Cliffe

---

<div class="post-metadata">

**Author:** ![cliffeh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/df705f/32.png) [@cliffeh](https://www.ruby-forum.com/u/cliffeh)\
**Post date:** [September 22, 2006, 4:07pm UTC](https://www.ruby-forum.com/t/pass-parameters-to-controller-from-link-to-remote/69574/2 "2006-09-22T16:07:55Z")

</div>

You can pass parameters in via the link\_to\_remote call, in the :url  
value.

For instance:

link\_to\_remote(‘Delete’, :url =\> {:action =\> ‘delete’, :del\_type =\>  
‘message’})

or

link\_to\_remote(‘Delete’, :url =\> {:action =\> ‘delete’, :del\_type =\>  
‘list’})

In your controller, you can access params[:del\_type] and it will either  
be ‘list’ or ‘message’ and you can act accordingly.

c.

cliffeh wrote:

> I have an e-mail-type app where users will see either a list of message  
> headers, or a single message. From either view, they need to be able to  
> delete a message.
> 
> When delete is called from the list view, I use :loading =\>  
> visual\_effect(:fade, ‘my\_id’), then in the controller the record is  
> actually deleted and nothing needs to be rendered back. This works  
> fine.
> 
> However, if delete is called from the expanded message view, I need the  
> controller to render the list of messages again.
> 
> Any suggestions on how I can either tell from the controller where a  
> request came from, or else pass something with the link\_to\_remote? Is  
> there a :locals parameter? It doesn’t make sense to have 2 methods in  
> the controller - say a delete\_from\_list and delete\_from\_message.
> 
> Thanks,  
> Cliffe
