Forum: Ruby on Rails Routing and AJAX problem.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Prateek (Guest)
on 2009-03-10 08:50
(Received via mailing list)

I am having a problem in using AJAX in Rails(I am trying for the first
time), and I am pretty sure it is because of routing. This is my code

As far I knew the URL's were supposed to be like "/controller/action/
id" but when I do "/controller/action" it throws an error "Could not
find model with ID=action" and that is why my AJAX calls aren't
working. I do not wish to use form_for_remote or link_to_remote as I
need to make these calls from JS.

Could someone please help me out.

MaD (Guest)
on 2009-03-10 09:00
(Received via mailing list)
you should read up on REST. maybe start here:
on 2009-03-10 09:09
(Received via mailing list)
On 10 Mar., 07:49, Prateek <removed_email_address@domain.invalid> wrote:
> Could someone please help me out.

When you're using RESTful routes (map.resources) you should not
request /projects/create.json but /projects.json. I would simply
change your code into this: Two changes have
been made: I've changed "/projects/create.json?
authenticity_token=0000&project[title]=lala" into "/projects.json?
project[title]=lala" and added a line saying
"protect_from_forgery :except => :create" in the ProjectsController.

David K.
Prateek (Guest)
on 2009-03-13 13:50
(Received via mailing list)
Thanks a lot. Working now.
@MaD - Thanks for the link
This topic is locked and can not be replied to.