开发者

Rails - CanCan - If can? works on page load but not via a AJAX Partial

开发者 https://www.devze.com 2023-02-05 21:27 出处:网络
Hello I have the following in a partial. <% if can? :update, @permission %> Yes <% end %> For the exact same user, when this loads via html this works great. But when I render that par

Hello I have the following in a partial.

<% if can? :update, @permission %>
Yes
<% end %>

For the exact same user, when this loads via html this works great. But when I render that partial via ajax, as so:

$('#current').html('<%=escape_javascript(render :partial =>"permissions/teammembers", :locals => {:teammembers => @teammembers}) %>');

Then cancan is return false, why is that? the current_user is开发者_JAVA百科 the same person making the request?

Thanks


Check if @permission is not nil. Throw it and see if it is ok.

0

精彩评论

暂无评论...
验证码 换一张
取 消