Rails 4 Plugin: missing_template_406
Modifies ActionController::Base
such that, in production,
ActionView::MissingTemplate
exceptions are caught and an HTTP 406-Not
Acceptable response is rendered.
This gem is verified to work with the build matrix including Rails 4.0.X, 4.1.X, 4.2.X (X being latest), and Ruby 2.0.0, 2.1.10, 2.2.5, 2.3.1.
Rails 5 raises a ActionController::UnknownFormat
when attempting to request a
format that does not have a template. In production mode, this exception is
implicitly converted to a 406-Not Acceptable HTTP response. As a result of
Rails 5 including the desired behavior, the 406 response, this gem will fail to
install when included in a Rails 5 gemfile.
Usage
To take advantage of this plugin simply add missing_template_406 to your gemfile:
gem 'missing_template_406'
Motivation
Motivation for this plugin stemmed from this blog post by Robert Pankowecki:
http://blog.arkency.com/2016/07/respond-to-format-is-useful-even-without-multiple-formats/