New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 删除评论会出现异常 #57

Closed
jobslong opened this Issue Oct 8, 2014 · 5 comments

Comments

Projects
None yet
2 participants
@jobslong

jobslong commented Oct 8, 2014

bug

@summerblue summerblue added the bug label Oct 8, 2014

@summerblue

This comment has been minimized.

Show comment
Hide comment
@summerblue

summerblue Oct 8, 2014

Owner

收到, 我等会看看去.

Owner

summerblue commented Oct 8, 2014

收到, 我等会看看去.

@jobslong

This comment has been minimized.

Show comment
Hide comment
@jobslong

jobslong Oct 9, 2014

我看了一下错误,应该是删除的时候ajax会重复调用,当删除这条回复之后,有时候会有同样的删除请求被发送过来,但是找不到该资源的情况也没有抛出异常,导致出现错误页面:

ErrorException :­app/­controllers/­RepliesController.php28

 public function delete($id)
 {
        $reply = Reply::find($id);
        $this->authorOrAdminPermissioinRequire($reply->user_id);
        $reply->delete();
 }

是不是当资源找不到的时候抛出一下异常 ?

jobslong commented Oct 9, 2014

我看了一下错误,应该是删除的时候ajax会重复调用,当删除这条回复之后,有时候会有同样的删除请求被发送过来,但是找不到该资源的情况也没有抛出异常,导致出现错误页面:

ErrorException :­app/­controllers/­RepliesController.php28

 public function delete($id)
 {
        $reply = Reply::find($id);
        $this->authorOrAdminPermissioinRequire($reply->user_id);
        $reply->delete();
 }

是不是当资源找不到的时候抛出一下异常 ?

@summerblue

This comment has been minimized.

Show comment
Hide comment
@summerblue

summerblue Oct 9, 2014

Owner

表象是这样的, 其实是 pjax 问题, 请求了两次.

Owner

summerblue commented Oct 9, 2014

表象是这样的, 其实是 pjax 问题, 请求了两次.

@summerblue

This comment has been minimized.

Show comment
Hide comment
@summerblue

summerblue Oct 9, 2014

Owner

解决了, 在使用 pjax 的时候犯了一个错误, Pjax 原本就是通过 get 方法来获取信息的, 并不适用于 Action 类的操作, 如: 更新数据用的 post, 删除数据用 delete.

区分开就行了, 所有动作都是用表单提交, pjax 对表单会跳过, 使用原始的请求方式.

0e1efca

Owner

summerblue commented Oct 9, 2014

解决了, 在使用 pjax 的时候犯了一个错误, Pjax 原本就是通过 get 方法来获取信息的, 并不适用于 Action 类的操作, 如: 更新数据用的 post, 删除数据用 delete.

区分开就行了, 所有动作都是用表单提交, pjax 对表单会跳过, 使用原始的请求方式.

0e1efca

@summerblue summerblue closed this Oct 9, 2014

@jobslong

This comment has been minimized.

Show comment
Hide comment
@jobslong

jobslong Oct 9, 2014

嗯 学习。

jobslong commented Oct 9, 2014

嗯 学习。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment