1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/lib/abstract_controller
Carlos Antonio da Silva 618d5317d3 Move the null mime type to request.format
TLDR: always return an object that responds to the query methods from
request.format, and do not touch Mime::Type[] lookup to avoid bugs.

---

Long version:

The initial issue was about being able to do checks like
request.format.html? for request with an unknown format, where
request.format would be nil.

This is where the issue came from at first in #7837 and #8085
(merged in cba05887dc), but the
implementation went down the path of adding this to the mime type
lookup logic.

This unfortunately introduced subtle bugs, for instance in the merged
commit a test related to send_file had to be changed to accomodate the
introduction of the NullType.

Later another bug was found in #13064, related to the content-type being
shown as #<Mime::NullType:...> for templates with localized extensions
but no format included. This one was fixed in #13133, merged in
43962d6ec5.

Besides that, custom handlers were not receiving the proper template
formats anymore when passing through the rendering process, because of
the NullType addition. That was found while migrating an application
from 3.2 to 4.0 that uses the Markerb gem (a custom handler that
generates both text and html emails from a markdown template).

---

This changes the implementation moving away from returning this null
object from the mime lookup, and still fixes the initial issue where
request.format.zomg? would raise an exception for unknown formats due to
request.format being nil.
2013-12-23 16:16:49 -02:00
..
railties Rely on a public contract between railties instead of accessing railtie methods directly. 2011-11-23 19:06:45 +00:00
asset_paths.rb 🔥 Rails asset id support 2012-10-15 09:47:16 -05:00
base.rb Revert "Port all remaining self.protected_instance_variables to class methods" 2013-09-02 23:18:02 +02:00
callbacks.rb Execute conditional procs on controller filters only for current action. 2013-08-10 09:13:20 -07:00
collector.rb Improve a couple exception messages related to variants and mime types 2013-12-03 22:23:12 -02:00
helpers.rb move MissingHelperError out of the ClassMethods module. 2013-07-12 15:34:29 +02:00
logger.rb avoid empty api pages 2012-04-08 01:56:41 +05:30
rendering.rb Move the null mime type to request.format 2013-12-23 16:16:49 -02:00
translation.rb change useless gsub to tr 2013-03-05 09:33:42 -05:00
url_for.rb Clean up module docs [ci skip] 2012-03-07 01:04:14 +05:30