# Rails complaining about {:method=\>:get} on an AJAX call

**URL:** <https://www.ruby-forum.com/t/rails-complaining-about-method-get-on-an-ajax-call/123119>\
**Category:** Rails\
**Created:** [December 14, 2007, 6:29am UTC](https://www.ruby-forum.com/t/rails-complaining-about-method-get-on-an-ajax-call/123119 "2007-12-14T06:29:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 14, 2007, 6:29am UTC](https://www.ruby-forum.com/t/rails-complaining-about-method-get-on-an-ajax-call/123119/1 "2007-12-14T06:29:50Z")

</div>

Hello guys,

I hope you can point me in the right direction. I just moved to Rails  
2.0 and I’m having some problems.  
I’m using ExtJS (excellent widget library btw), to make my  
application.

Right now I’m testing a login form that I’m developing for a web  
application, the login form sends the info throught AJAX.

I get a 404 error from the server, it complains that the method used  
to pass the values was GET, but I’m pretty sure it was a POST, here is  
the firebug error:  
 → POST [http://localhost:3000/session/404](http://localhost:3000/session/404) (313ms)

And this is what firebug report in the [Headers | Post | Response]:

# [Post]

module=login&login=Sergio  
%20Loredo&password=cevival&authenticity\_token=7e4f20fa543cae7c01921acf0c772d81fdb81138

As you can see the [Post] tab in firebug is representing the data I  
sent as a GET string. Why is that?

# [Response]

Routing Error

No route matches “/” with {:method=\>:get}

I’m clueless as to why is this behaving this way, aren’t AJAX calls  
supposed to be always POST?

I’m using restful\_authentication, and the URL the form is trying to  
POST to is /session (I have map.resource :session).

If you need more info, just tell me and I will reply with it.

Thanks in advance,  
Adrián.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 14, 2007, 6:35am UTC](https://www.ruby-forum.com/t/rails-complaining-about-method-get-on-an-ajax-call/123119/2 "2007-12-14T06:35:08Z")

</div>

What’s the code you’re using to make the ajax call?

On Dec 14, 2007 3:59 PM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> # application, the login form sends the info throught AJAX.
> 
> Routing Error  
> If you need more info, just tell me and I will reply with it.
> 
> Thanks in advance,  
> AdriÃ¡n.
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 14, 2007, 6:42am UTC](https://www.ruby-forum.com/t/rails-complaining-about-method-get-on-an-ajax-call/123119/3 "2007-12-14T06:42:44Z")

</div>

I’m using ExtJS as I said, and it abstracts the AJAX calling. Here is  
the code for the form:

This is the code of the form:

```auto
var submitUrl = '/session';

var formPanel = new Ext.form.FormPanel({
            baseCls: 'x-plain',
                        method: 'post',
            baseParams: {
              module: 'login'
            },
            bodyStyle: 'background:#f9f9f9 none; color:#222; padding:5px
35px;',
            defaults: {
              width: 200
            },
            defaultType: 'textfield',
            frame: false,
            height: 70,
            id: 'login-form',
            items: [{
                fieldLabel: 'Nombre de usuario',
                name: 'login',
                value: 'usuario'
            },{
                fieldLabel: 'Contraseña',
                inputType: 'password',
                name: 'password',
                value: 
'contraseña' },{
                            inputType: 'hidden',
                            name:
Ext.get('authenticity_token').dom.getAttribute('name'),
                            hidden: true,
                            value:
Ext.get('authenticity_token').dom.getAttribute('value')

                        }],
            labelWidth:120,
            region: 'south',
            url: submitUrl
        });
```

Or can I get the info you want from firebug? if so, if you tell me I  
can get it for you.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 14, 2007, 6:51am UTC](https://www.ruby-forum.com/t/rails-complaining-about-method-get-on-an-ajax-call/123119/4 "2007-12-14T06:51:29Z")

</div>

Yeah, what I’m trying to understand is why would my POST parameters  
end like a GET string, if Firebug is clearly showing a POST.

If I understand why that happens, I might be able to correct the error.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 14, 2007, 6:45am UTC](https://www.ruby-forum.com/t/rails-complaining-about-method-get-on-an-ajax-call/123119/5 "2007-12-14T06:45:39Z")

</div>

Um. Wow. I have no idea about ExtJS sorry.

That seems to be a huge amount of code, I hope it does something useful.

On Dec 14, 2007 4:12 PM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> baseCls: 'x-plain',
> defaultType: 'textfield',
> name: 'password',
> labelWidth:120,
> region: 'south',
> url: submitUrl
> });
> 
> ```
> 
> [/CODE]
> 
> Or can I get the info you want from firebug? if so, if you tell me I  
> can get it for you.
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 14, 2007, 7:23am UTC](https://www.ruby-forum.com/t/rails-complaining-about-method-get-on-an-ajax-call/123119/6 "2007-12-14T07:23:40Z")

</div>

Shame on me, it was a problem with the Rails app, it was doing a  
redirect to another page in the method that was invoked in the AJAX  
call.

I think that explains why I was getting my POST params as a GET  
string.

Well at least I hope this can help someone with my same problem 😉
