My partial wasn't loading because of CanCan authorization. How can I debug that?

≯℡__Kan透↙ 提交于 2019-12-12 03:49:15

问题


I was having this problem trying to render a partial via an asynchronous request from my users views.

The problem was that CanCan was not authorizing the call, because it was inside a new action that I created on user_controller.rb. I am new to Rails and I thought that putting :edit on the ability class was enough.

I caught this error because I removed the remote: true from my link, so it can render the view via a http request. Don't as me why I did that. Begginer's luck!

My question is: how could I have debugged that error if not by luck?


回答1:


You could have added test cases that accounted for the rendering of that partial, for instance (with rspec):

response.should render_template(:partial => 'partial_name')


来源:https://stackoverflow.com/questions/15682883/my-partial-wasnt-loading-because-of-cancan-authorization-how-can-i-debug-that

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!