# How to test for values in ajax form

**URL:** <https://www.ruby-forum.com/t/how-to-test-for-values-in-ajax-form/71932>\
**Category:** Rails\
**Created:** [October 12, 2006, 1:48pm UTC](https://www.ruby-forum.com/t/how-to-test-for-values-in-ajax-form/71932 "2006-10-12T13:48:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 12, 2006, 1:48pm UTC](https://www.ruby-forum.com/t/how-to-test-for-values-in-ajax-form/71932/1 "2006-10-12T13:48:28Z")

</div>

I want to see if the values are making it over from my form into my  
controller.  
What’s the way to test that ?

TIA  
Stuart

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 12, 2006, 1:58pm UTC](https://www.ruby-forum.com/t/how-to-test-for-values-in-ajax-form/71932/2 "2006-10-12T13:58:30Z")

</div>

On 10/12/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want to see if the values are making it over from my form into my  
> controller.  
> What’s the way to test that ?
> 
> TIA  
> Stuart
> 
> –

You could always use a params.inspect or params.to\_yaml to see what’s in  
it.

Do you have fire bug for mozilla? This will show you request and  
response,  
and also allow you to search through the dom. It’s pretty sweet.

[https://addons.mozilla.org/firefox/1843/](https://addons.mozilla.org/firefox/1843/)

Hope that helps

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 12, 2006, 2:04pm UTC](https://www.ruby-forum.com/t/how-to-test-for-values-in-ajax-form/71932/3 "2006-10-12T14:04:35Z")

</div>

On 10/12/06, Daniel N [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Stuart  
> > [https://addons.mozilla.org/firefox/1843/](https://addons.mozilla.org/firefox/1843/)
> 
> Hope that helps

I have firebug. Probably I need to learn how to use it.

Stuart

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 12, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/how-to-test-for-values-in-ajax-form/71932/4 "2006-10-12T15:13:55Z")

</div>

On 10/12/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > 
> > 
> > response, and also allow you to search through the dom. It’s pretty sweet.
> 
> Sorry, because I’m not quite sure how to use the inject in this case. My  
> form is ajaxed, (set up with using observe\_form), the controller /  
> action is  
> where the values should be showing up. What I can’t figure out is how  
> to  
> see if anything is showing up in the controller ?  
> Not sure if this makes sense

Stuart

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 12, 2006, 6:58pm UTC](https://www.ruby-forum.com/t/how-to-test-for-values-in-ajax-form/71932/5 "2006-10-12T18:58:36Z")

</div>

Stuart Fellowes wrote:

> > Sorry, because I’m not quite sure how to use the inject in this case. My  
> > form is ajaxed, (set up with using observe\_form), the controller /  
> > action is  
> > where the values should be showing up. What I can’t figure out is how  
> > to  
> > see if anything is showing up in the controller ?

Personally, I use three different techniques. These all work well, it  
just depends on the situation.

1. Add the following line to the RJS template for the action (or, if you  
aren’t using RJS templates, create a temporary one for the action you  
want to watch, just for testing purposes, containing only this line):

page.alert params.inspect

This will give you your params hash in a pop-up JavaScript window in  
your browser.

1. You ARE using ‘tail -f log/development.log’ every time you run  
‘script/server’, right? If not, you are making development twice as  
difficult as it needs to be, and missing out on a ton of information  
Rails gives you about your application as it runs.

One of those pieces of information is the params hash. It gets logged  
every time an action is triggered. BUT, there’s so much other  
information scrolling by, it’s easy to miss! What can be done?

Easy: open another terminal window and run: ‘tail -f log/development.log  
| grep Parameters’. Now every time an action is triggered and the params  
hash gets logged, that’s all you’ll see.

1. Install firebug and learn how to use it 😉 Admittedly, this only  
shows what data is being sent to the application, not what your  
application’s action is actually receiving, so it won’t help fix bugs  
where (for example) you’re accidentally sending the request to the wrong  
URL, but on the other hand, it shows both the request and the response,  
which can be very useful.

Hope this helps!

- Chris

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 18, 2006, 10:38am UTC](https://www.ruby-forum.com/t/how-to-test-for-values-in-ajax-form/71932/6 "2006-10-18T10:38:54Z")

</div>

On 10/12/06, Chris G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> your browser.  
> This is a good thing to know …appreciate it !

1. You ARE using ‘tail -f log/development.log’ every time you run

> hash gets logged, that’s all you’ll see.  
> Right - since I’ve actually fixed a few more things I’m noticing the  
> params  
> coming through (I think) -

Processing AjaxsearchController#list (for 127.0.0.1 at 2006-10-12  
11:05:16)  
[POS  
T]  
Session ID: ea2c016d29ba637d81895fabc3a2f692  
Parameters: {“asearch”=\>“position[category\_id][]=1”, “action”=\>“list”,  
“controller”=\>“ajaxsearch”, “position”=\>{“city”=\>“New York”,  
“title”=\>“”,  
“state\_id”=\>[  
“2”]}}

I guess though it doesn’t look like my find code is getting updated. In  
a PP  
printout it looks like the find conditions are loading once with the  
default  
values of the form (when it first loads)

1. Install firebug and learn how to use it 😉 Admittedly, this only

> shows what data is being sent to the application, not what your  
> application’s action is actually receiving, so it won’t help fix bugs  
> where (for example) you’re accidentally sending the request to the wrong  
> URL, but on the other hand, it shows both the request and the response,  
> which can be very useful.

Well it’s good for something and I was able to track down a few problems  
with it.

Stuart
