module ActionDispatch::Routing::Mapper::Resources
def collection(&block)
and route to the search action of `PhotosController`. It will also create the
This will enable Rails to recognize paths such as `/photos/search` with GET,
end
end
get 'search'
collection do
resources :photos do
To add a route to the collection:
def collection(&block) unless resource_scope? raise ArgumentError, "can't use collection outside resource(s) scope" end with_scope_level(:collection) do path_scope(parent_resource.collection_scope, &block) end end