Rails 6.0.0.rc2 changed the behaviour of the content_type method to include the charset media type parameter. This broke our content type check, which assumed no parameters would be present. A new media_type method was also added that returns the media type without parameters.
We can fix the content type check on Rails 6.0 while staying compatible with older Rails versions by using the media_type method if it exists, and falling back to the content_type method otherwise.
Fixes https://github.com/intercom/intercom-rails/issues/312.
Rails 6.0.0.rc2 changed the behaviour of the
content_type
method to include thecharset
media type parameter. This broke our content type check, which assumed no parameters would be present. A newmedia_type
method was also added that returns the media type without parameters.We can fix the content type check on Rails 6.0 while staying compatible with older Rails versions by using the
media_type
method if it exists, and falling back to thecontent_type
method otherwise.