活动管理员索引页面我想根据某些条件隐藏列,但下面的代码不是wokrking。
index title: 'Comp-Off', download_links: false do
selectable_column
if proc{ !(current_user.has_role? :Employee) }
column("Name", sortable: :name) {|resource| resource.employee.name}
column("ID", sortable: :employee_id) {|resource| resource.employee.employee_id}
end
column :status
end
如何解决这个问题。
答案 0 :(得分:1)
使用以下代码实现。
index title: 'Comp-Off', download_links: false do
selectable_column
column("Name", sortable: :name) {|resource| resource.employee.name} if !(current_user.has_role? :HRMS_Employee)
column("ID", sortable: :employee_id) {|resource| resource.employee.employee_id} if !(current_user.has_role? :HRMS_Employee)
end
column :status
end