# Access variables in controller from link\_to\_remote

**URL:** <https://www.ruby-forum.com/t/access-variables-in-controller-from-link-to-remote/138632>\
**Category:** Rails\
**Created:** [May 26, 2008, 6:32am UTC](https://www.ruby-forum.com/t/access-variables-in-controller-from-link-to-remote/138632 "2008-05-26T06:32:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alais](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/958977/32.png) [@alais](https://www.ruby-forum.com/u/alais)\
**Post date:** [May 26, 2008, 6:32am UTC](https://www.ruby-forum.com/t/access-variables-in-controller-from-link-to-remote/138632/1 "2008-05-26T06:32:47Z")

</div>

This is really easy and simple but…

I have  
view \<%=link\_to\_remote ‘this’, {:url=\>{:action=\>‘action’}, :with =\>  
“‘name=’ + $(‘text\_field\_id’).value” } %\>

When I’m in the controller, how do I access the variable ‘name’? I  
thought it was params[:name] but that returns nil…

Thanks

---

<div class="post-metadata">

**Author:** ![alais](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/958977/32.png) [@alais](https://www.ruby-forum.com/u/alais)\
**Post date:** [May 26, 2008, 7:05am UTC](https://www.ruby-forum.com/t/access-variables-in-controller-from-link-to-remote/138632/2 "2008-05-26T07:05:44Z")

</div>

On Mon, 2008-05-26 at 06:32 +0200, s. \ wrote:

> This is really easy and simple but…
> 
> I have  
> view \<%=link\_to\_remote ‘this’, {:url=\>{:action=\>‘action’}, :with =\>  
> “‘name=’ + $(‘text\_field\_id’).value” } %\>
> 
> When I’m in the controller, how do I access the variable ‘name’? I  
> thought it was params[:name] but that returns nil…

* * *

look in your logs (presumably log/development.log) to see what it was  
that was posted back to your controller.

Craig

---

<div class="post-metadata">

**Author:** ![alais](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/958977/32.png) [@alais](https://www.ruby-forum.com/u/alais)\
**Post date:** [May 26, 2008, 12:10pm UTC](https://www.ruby-forum.com/t/access-variables-in-controller-from-link-to-remote/138632/3 "2008-05-26T12:10:32Z")

</div>

On 26 May 2008, at 06:05, Craig W. wrote:

> * * *
> 
> look in your logs (presumably log/development.log) to see what it was  
> that was posted back to your controller.

In particular that will screw up if your text field contains an  
ampersand. You should use encodeURIComponent to guard against that.

Fred
