在我的应用程序中使用cancancan和activeadmin宝石,在cancan gem中我想将params传递给我们。
controller.rb
controller do
def scoped_collection
end_of_association_chain.accessible_by(current_ability, params[:project_id]) # passing params
end
end
ability.rb
if ((user.has_role? :LA_Tracker_Manager) && (user.has_application? :LA_Tracker))
can :manage, Job, project_id: params[:project_id] # getting the params heree
end
if (user.has_role? :LA_Tracker_Analyst)
can [:read, :update], Job, employee_id: user.employee.id
end
以上代码无效。如何实现这一点。