I have the following routes:
resources :boilerplates
resources :projects do
resources :boilerplates
end
The Boilerplate model looks like this:
class Boilerplate < ActiveRecord::Base
scope :originals, -> { where(prototype_id: nil) }
end
My controller looks like this:
class BoilerplatesController < InheritedResources::Base
load_and_authorize_resource
belongs_to :project, optional: true
end
When the URL /boilerplates is opened, I want to display all boilerplates with the originals scope.
When the URL /projects/123/boilerplates is opened, I want the originals scope not to be active.
How can this be achieved?
I just found a way to do this myself. In
BoilerplatesController: