🖥
Rails: How to set permissions for each action in CanCan
Specify as follows.
def initialize(user) can :update, ExampleClass can :create, ExampleClass end
Let's specify four types of CRUD (Create / Read / Update / Delete).
Note that edit / new / index / show does not exist because it is not strictly an "action name". For example, if you allow update with CanCan, Rails will allow two actions, update and edit.
Correspondence is as follows. (Specified in CanCan => action in Rails)
- read => index + show
- update => update + edit
- create => new + create
- delete => delete
- manage => all the above actions
-A note because it did not hit even if it is gugging with "CanCan action authority". -An easy way to separate administrators and general users with Cancan-Based on the setting of roles (authorization) for each user type .
Original by
Rails: CanCanでアクションごとに権限を設定する方法
About
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。
公開日時
2019-04-16
Discussion