2

I'm trying to define an ability:

# customer.rb
class Customer
  include Mongoid::Document

  has_many :accounts
end

class Account
  include Mongoid::Document

  belongs_to :site
end

# ability.rb
can :manage, Customer, accounts: { :site_id.in => user.managed_site_ids }

# customers_controller.rb
Customer.accessible_by(current_ability)

It's always returns empty result, and I am not sure, but I think because mongoid doesn't support join query. Do you know what's wrong, or other alternatives?

Samnang
  • 5,536
  • 6
  • 35
  • 47

0 Answers0