当同时使用 Cancan 和 Best_In_Place 时,如何说“老师”仅更新模型的某些属性(例如模型“书”),而他/她无法更新该模型的其他属性。我知道 Cancan 尚不支持属性授权,因为它仍在 2.0 中开发,所以我想到的第一件事是使用这样的东西:
cannot :all, Book
if is_teacher?
can :update_certain_attribute, Book
end
但由于我想使用 Best_In_Place,我的初步研究告诉我,我只能使用属性进行 Best_In_Place 更新,如下所示
<%= best_in_place @book, :certain_attribute, :type => :input %>
而不是方法:
<%= best_in_place @book, :update_certain_attribute, :type => :input %>
处理这个问题的最佳方法是什么?谢谢 :)