我已经尝试了大约 2 个小时来完成这项工作,但我根本做不到。我的问题找到的答案似乎都不起作用。
我有一个 has_many :通过这样的关联:
class Request < ActiveRecord::Base
has_many :dialogs
has_many :companies, :through => :dialogs
class Dialog < ActiveRecord::Base
belongs_to :request
belongs_to :company
在我的能力.rb 文件中,我试图让公司只能看到它的请求(即查看 current_user id 是否在特定请求的对话框中)。
我尝试了很多方法,但没有成功。我必须以某种方式接近,但无法弄清楚:
can [:show, :destroy], Request, :dialogs => {:company_id => user.rolable.id}
任何人都可以帮忙吗?