CanCan difference between :read and [:index, :show]?

前端 未结 1 2010
北荒
北荒 2021-02-06 01:41

According to all documentation, the :read action is aliased to both :index and :show:

alias_action :index, show, :to =>         


        
1条回答
  •  感情败类
    2021-02-06 01:55

    I posted this as an issue on GitHub. Ryan responded with the following:

    Both the :index and :show actions point to the :read action. But when CanCan authorizes a parent resource it uses the :read action directly which is why you're seeing this behavior.

    I think this has caused confusion before, so I will change the internal behavior to never use the :read action directly. Instead of a :parent resource I'll change it to use :show and for the accessible_by default I will use :index instead of :read. Thanks for bringing this to my attention.

    https://github.com/ryanb/cancan/issues/302#comment_863142

    0 讨论(0)
提交回复
热议问题