1
내 응용 프로그램에서 cancancan 및 activeadmin gem을 사용하고 있습니다. 사용자 정의 작업이 작동하지 않습니다.cancancan 사용자 정의 작업이 작동하지 않습니다.
if ((user.has_role? :HRMS_Supervisor) && (user.has_application? :HRMS))
can :manage, User
can :approve, User // custom action
end
if ((user.has_role? :HRMS_Employee) && (user.has_application? :HRMS))
can :read, Employee
can :manage, User
can :employee_access, User // custom action
end
내 ActiveAdmin을 파일
ActiveAdmin.register Teleworker do
scope :pending, default: true
scope :approved
scope :rejected, if: proc{ can? :employee_access, current_user }
scope :all
index do
selectable_column
column "Action" do |resource|
links = ''.html_safe
if can? :approve, current_user
links += link_to "approve", resource_path(resource), class: "member_link view_link"
end
end
end
거부 된 범위와 LINK_TO ability.rb "승인"모두 역할에 표시됩니다. 이 문제를 해결하는 방법.
... 또한 맞춤 동작을 승인해야합니다. https://github.com/CanCanCommunity/cancancan/wiki/Authorizing-controller-actions – nistvan
감사합니다. –