2

我正在尝试定义一种能力:

# 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)

它总是返回空结果,我不确定,但我认为是因为 mongoid 不支持连接查询。你知道什么是错的,或者其他的选择吗?

4

0 回答 0