The association is as follows
Company has_many :orders
The permissions are set as follows
if @resource.has_cached_role?(:client_admin)
can %i[read create confirm], Order, company_id: resource_company_ids
end
def resource_company_ids
@resource_company_ids ||= Company.where(id: @resource.company_id)
.or(Company.where(parent_id: @resource.company_id))
.pluck(:id)
end
#1) The client admin logging in to a company can create orders for that company and also for its child companies.
#2) Also, there are company which does not have child companies.
When a user is logged in, i need to check if the user has order create permissions for multiple companies(scenario #1)
How to achieve this using cancancan?
Any help would be appreciated.
i think a block conditions maybe help