问题
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