cancancan阻止嵌套属性的条件:新操作

时间:2017-10-26 07:24:52

标签: ruby-on-rails cancancan

我有两辆资源车和车,它们通过车辆连接汽车,汽车有车辆。

 ‘%y’ Year without century (00-99).  On input, values 00 to 68 are
      prefixed by 20 and 69 to 99 by 19 - that is the behaviour
      specified by the 2004 and 2008 POSIX standards, but they do
      also say ‘it is expected that in a future version the default
      century inferred from a 2-digit year will change’.

现在,如果我想在车辆的属性成本超过5时仅加载汽车的新动作。

class VehiclesController < ApplicationController
  load_and_authorize_resource find_by: :title

class CarsController < ApplicationController
  load_and_authorize_resource :vehicle, find_by: :title
  load_and_authorize_resource through: :vehicle, singleton: true

我无法获得理想的结果。对于新操作,尚未创建对象是无法访问该属性还是我需要在控制器中指定其他任何内容?

0 个答案:

没有答案