Rails 3 - Ajax Put request gives 404, yet it works -
I am updating a job status from my deal overview page where I display my list of tasks for that deal
This works, the work gets updated, however, I get a dirty 404 error.
Any thoughts?
js / coffeescript
jquery -> $ (". Full_task"). Live "click", - & gt; Task_id = $ (this) .attr ("value") "Clicked on the checkbox" + task_id $ ('ul # tasks'). Sortable "Refresh" $ .jax url: "tasks /" + task_id Data: "& Work [Is_completed] = 2" Type: "PUT" Success: - & gt; However, the requirement to do this "$ I" is however, that it should be done with Ajax. Thanks Advance!
EDIT: Requested Information < P> routing error
& lt; h1 & gt; routing error & lt; / h1 & gt; Show ",: id = & gt; # & lt; Deal ID: 1, Title: Blue, made_t: "2011-09-02 00:08:24", updated_at: "2011-09-02 00:08:24", account_id: 1>,: format = & g T; # id: 39, title: "new tdsfsdf", position: 25, user_id: zero, deal_id: 1, created_t: "2011-09-02 02:49:09", updated_at: "2011- The resources of the accounts are: User resources: 2, user_width_complete: null & gt;} route
resources: user resources: Posted in: Sort, but: Member Resources: Post jobs: sort, on :: collection and end end
answer-block block
Answer the DEF response. Format | | If the @ task.update_attributes (params [: task]) format.html {redirect_to ([@ task.deal, @task], notice = & gt; 'the job was updated successfully'.}} Format.xml {head : Ok} Format.js {Render: None = & gt; True} else format.html {rendere: action = & gt; "Edit"} format.xml {Render: xml = & gt; @ Task. Errors, : Status = & gt;: Unprocessable_entity} format.js {Render: None => True =} End End Rock / grep
MacBook-Pro-2: Responsible jbeasley6651 $ rake routes | Grep work sort_account_deal_tasks POST /accounts/:account_id/deals/:deal_id/tasks/sort(.format) {: action = & gt; "sort" ,: controller = & gt; ; "Work"} account_deal_tasks G ET / accounts /: account_id / deals /: deal_id / work (.: Format) {: verb = & gt; "index" ,: admin = & gt; "work"} POST / accounts /: account_id / deals /: deal_id /tasks (.:format) {: verb = & gt; "create" ,: administrator = & gt; "work"} new_account_deal_task received /accounts/:account_id/deals/:deal_id/tasks/new(.:format) { : Action = & gt; "New",: controller = & gt; "Task"} edit_account_deal_task received /accounts/:account_id/deals/:deal_id/tasks/:id/edit(.:format) {: verb => "Edit",: admin = & gt; "Tasks"} Account_deal_task GET /accounts/:account_id/deals/:deal_id/tasks/:id(.format) {: Action => "Show",: Controller => "Task"} PUT / accounts /: account_id / deals /: Deal_id / tasks /: id (.: Format) {: action = & gt; "Update",: admin = & gt; "Work"} DELETE / accounts /: account_id / deals /: deal_id / tasks /: id (.: Format) {: action = & gt; "Destroyed" ,: controller => "Work"}
You have to add an account to your redirects, like
add it as @account, even though you are referring to it to change. # Parameters [: account_id] should also work: Format.html {redirect_to ([@ account, @ task.deal, @task], ...)} In addition, as As stated in the comments, your Ajax request is not asking for Javascript, but HTML should do what you should do with Christian PD and add the dataType: script to the option to specify JS $ Ajax url: "work /" + Task_id data: "and works [is_completed] = 2" Type: "PUT" Data type: "script" success: - & gt; $ (This) .addClass "done"
Comments
Post a Comment