LoginSignup
0
0

More than 1 year has passed since last update.

Rails: How to set permissions for each action in CanCan

Last updated at Posted at 2019-04-16

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

About this translattion

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0