Get Content Type of Request
You don't need to parse the content_type string, Rails has already done this for you. Just check:
request.format.symbol == :json
I would usually go for request.format
and request.content_type
for reading these header fields.
EDIT: found a bit more on this that might help: https://stackoverflow.com/a/1595453/624590