Skip to content

Configuring rails routes

Sarah edited this page Feb 21, 2017 · 5 revisions

If your solr ids happen to have dots in them, Rails is going interpret the dots as the separator between the file name and the file exension, and your documents won't be displayed on the show view. In order to fix that you can override the default routes like this:

MyApp::Application.routes.draw do
  ...
  blacklight_for :catalog, constraints: { id: /[a-zA-Z0-9_.:]+/, format: false }
  ...
end

For newer versions of Blacklight where blacklight_for has been deprecated, you can add constraints to the resource route for solr_documents like so:

resources :solr_documents, only: [:show], path: '/catalog', controller: 'catalog', constraints: { id: /[a-zA-Z0-9_.:]+/ } do
  concerns :exportable
end

See: http://guides.rubyonrails.org/routing.html#specifying-constraints for more details on rails routing and routing constraints.

Clone this wiki locally