TODO: <Insert clever marketing phrase here>
Filters give you the power to control the contents of a sitemap based on verbs, controller name, action name, and route name. The default configuration is to exclude everything except routes that have an action name of :index or :show. For most Rails apps, that should cover the general needs of generating a sitemap.
You can apply route filters using two methods: - Using exclude and include statements within a sitemap block. - Using exclude and include statements directly on the route.
MyApp::Application.routes.draw do # within the default sitemap block # exclude all "show" actions from all routes. exclude_actions :show root to: 'home#index' resources :contact # directly on the route. # re-include :show action for faqs resources :faqs, include_actions: :show # you could put the exclude_actions method here and get the same result. end
Note: Filters ARE NOT applied DURING the execution of a block. Filters are applied to the list of routes that are generated AFTER the block executes.
The following example encapsulates and applies filters to a sitemap block, however, contents are included in the default sitemap.
MyApp::Application.routes.draw do # included in default sitemap root to: 'home#index' resources :contact resources :faqs # using a block to encapsulate, however, contents are included in the default sitemap. sitemap do exclude_actions :show # excludes the "show" action from every route witnin the block resources :dvd_players resources :accessories # you could put the exclude_actions method here and get the same result. end end
Have a look at all of the example apps.