0
如果我有用户,客户端和请求型号如下:复杂条件
#user.rb
#client.rb
has_one :user
has_many :requests
#request.rb
belongs_to :client
我使用用户模型CanCanCan认证。 内部能力类我想指定客户端的能力。我想让用户只允许读取,更新属于他的请求。 她是我尝试:
def client
can [:read,:update], [Request], ['client_id = ?', user.client_id] do |client|
......something here
end
end