开发者

CanCan - Why does a can: create rule run when I'm not calling create?

开发者 https://www.devze.com 2023-02-10 04:47 出处:网络
I have the following in my ability.rb file: can :create, ThreadParticipation do |participation| Rails.logger.info \'XXXXXXX\'

I have the following in my ability.rb file:

can :create, ThreadParticipation do |participation|
  Rails.logger.info 'XXXXXXX'
end

What's strange is that when I call ThreadParticipation.new, that rule is rulling and I'm seeing t开发者_Python百科he logger output?

Why would can :create run when I'm just doing .new

Thanks


create is an alias for the actions new + create. This has been to done to simulate C-R-U-D behaviour. So,

:create = :new + :create
:read = :index + :show
:update = :edit + :update
:destroy = :destroy

Also,

:manage = :create + :read + :update + :destroy
0

精彩评论

暂无评论...
验证码 换一张
取 消