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 或类似的东西,并为不同的隐私选项赋予角色吗?
谢谢
我想您可以使用 CanCan,但在我看来,使用简单的条件语句会简单得多。
我会按照以下方式做一些事情:
def write_to_feed(user, action) unless user.private? unless user.private_action? action # Write to feed end end end write_to_feed @user, :post write_to_feed @user, :comment