我有以下路线:
resources :boilerplates
resources :projects do
resources :boilerplates
end
该Boilerplate
模型如下所示:
class Boilerplate < ActiveRecord::Base
scope :originals, -> { where(prototype_id: nil) }
end
我的控制器如下所示:
class BoilerplatesController < InheritedResources::Base
load_and_authorize_resource
belongs_to :project, optional: true
end
打开URL/boilerplates
后,我想显示originals
范围内的所有样板。
打开URL 时/projects/123/boilerplates
,我希望originals
范围不处于活动状态。
如何做到这一点?