Forum: Ruby on Rails xml_http_request : action not found?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2701c824d560c66c31b3d58d36fe17cf?d=identicon&s=25 itsastickup (Guest)
on 2009-01-28 21:38
(Received via mailing list)
I have this in a functional test:

xml_http_request :delete, person_movie_path(1,1)

and the error I get says the action cannot be found, as if the
':delete'  method is not being translated to the appropriate destroy
action. It works fine as an Ajax call from the browser.

What am I doing wrong?
96146b7a23174e2e024c06a49f845bb8?d=identicon&s=25 Jeffrey L. Taylor (Guest)
on 2009-01-28 22:19
(Received via mailing list)
Quoting itsastickup <lorrimang@googlemail.com>:
>
>
> I have this in a functional test:
>
> xml_http_request :delete, person_movie_path(1,1)
>
> and the error I get says the action cannot be found, as if the
> ':delete'  method is not being translated to the appropriate destroy
> action. It works fine as an Ajax call from the browser.
>

Probably wrong path.  Check the URL generated by
"person_movie_path(1,1)"
against the output of "rake routes".

HTH,
  Jeffrey
2701c824d560c66c31b3d58d36fe17cf?d=identicon&s=25 itsastickup (Guest)
on 2009-01-28 22:26
(Received via mailing list)
> > I have this in a functional test:
>
> > xml_http_request :delete, person_movie_path(1,1)
>
> > and the error I get says the action cannot be found, as if the
> > ':delete'  method is not being translated to the appropriate destroy
> > action. It works fine as an Ajax call from the browser.
>
> Probably wrong path.  Check the URL generated by "person_movie_path(1,1)"
> against the output of "rake routes".

That's what I thought but it checks out fine (I've practically blinded
myself examining rake routes). I even test the route in the test
method, and it passes. And it does work from the browser: indentical
path (and :delete method).

The error I get is :

ActionController::UnknownAction: No action responded to /people/1/
movies/1. Actions: create, create_guid, lots more methods here,
including "destroy"........
2701c824d560c66c31b3d58d36fe17cf?d=identicon&s=25 itsastickup (Guest)
on 2009-01-28 23:38
(Received via mailing list)
Ok, so the solution seems to be to forget paths and do the test like
this :

xml_http_request :delete,'destroy',{:id=>1,:person_id=>1}
This topic is locked and can not be replied to.