Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 cancan 进行授权。我有大约 50 个对象。有涉及 3 或 4 个对象的动作。当我设置ability.rb 时,我应该列出所有 50 个对象吗?如果一个特定的操作涉及更新超过 3 个对象,那么 can 方法是在什么对象上执行的。
您应该只授权实际与您的应用程序相关的对象。这样做,你保持它干燥(不要重复自己)。
如果一个动作涉及超过 3 个对象,那么您需要弄清楚它们是什么,因为如果您不这样做,那么您将来可能会遇到一些问题。
你能列出你所采取的行动吗?