JP Silvashy
JP Silvashy

Reputation: 48525

Using javascript to do a POST in rails

So I'm using this plugin: jquery-in-place-editor, I'm trying to make a POST request according to the docs, but I'm not sure what URL to do the POST to, I can't seem to get it right.

If I'm in the show view for the object, which in this case the path is: /quote_line_items/90

But when the script executes I get this error: No action responded to 90. Actions: create, destroy, edit, index, new, show, and update

Which URL would I want to put in the scripts url: parameter?

Update

I just tried this.

$(".editable").editInPlace({
  url: "/quote_line_items/update",
  show_buttons: true
});

And I also tried:

$(".editable").editInPlace({
  url: "/quote_line_items/update/90",
  show_buttons: true
});

just to see what would happen, however, after the form is submitted it shows the show action for that page in an Iframe where the form was, which makes sense I suppose, like it did a GET request or something.

Upvotes: 0

Views: 298

Answers (2)

Amiel Martin
Amiel Martin

Reputation: 4814

It looks like you moved on, but I do have an answer for you.

If quote_line_items is a map.resources, then what you want is a PUT to /quote_line_items/:id jquery-edit-in-place does a post, but what you want is a put, which you can fake with the _method attribute, so try this url: '/quote_line_items/90?_method=put'

Upvotes: 1

fernyb
fernyb

Reputation: 983

You probably want to do a post with _method as a parameter having the value update that is if you are doing restful routes.

Otherwise I would point to /quote_line_items/update with a post.

Upvotes: 1

Related Questions