How to test for values in ajax form

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

On 10/12/06, Dark A. [email protected] 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/

Hope that helps

On 10/12/06, Daniel N [email protected] wrote:

Stuart
https://addons.mozilla.org/firefox/1843/

Hope that helps

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

Stuart

On 10/12/06, Dark A. [email protected] 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

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 :wink: 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

On 10/12/06, Chris G. [email protected] 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 :wink: 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