What does this deprecation message mean for me to change when it references this block?
def json_response(object, status = :ok)
render json: object, status: status
end
Edit
The message:
Rails 6.1 will return Content-Type header without modification … use
#media_type
instead
I got the same error message when I was upgrading my app from Rails 5.2.3 to Rails 6.0.0-rc1
config/application.rb
# this was the line before
# config.load_defaults 5.2
config.load_defaults 6.0
In my case I had to change the version from 5.2
to 6.0
You can make the warning go away by adding this to your application.rb:
config.action_dispatch.return_only_media_type_on_content_type = false
You would need to make sure that if you are using content_type anywhere in your code that you replace that with media_type before making that change.
I also got the same error message when I was upgrading my app from Rails 5.2.4 to Rails 6.0.2.1.
For me the error was being caused by an older version of Turbolinks.
Upgrading from Turbolinks 5.1.0 to 5.2.1 made the warning go away.
After upgrade from Rails 5.2
to Rails 6.0.3.1
beside config.load_defaults
, mentioned by user1722721, i had to add config.autoloader = :classic
to application.rb for correct loading:
# config/application.rb
module YourAppName
class Application < Rails::Application
config.load_defaults 6.0
config.autoloader = :classic
# ...
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With