Skip to content

Commit f9415aa

Browse files
ydakukastas
authored andcommitted
Fix deprecation warning with Content-Type header without modification
1 parent c363207 commit f9415aa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/jsonapi/rails.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def self.install!
3737
# @return [NilClass]
3838
def self.add_errors_renderer!
3939
ActionController::Renderers.add(:jsonapi_errors) do |resource, options|
40-
self.content_type ||= Mime[:jsonapi]
40+
self.content_type = Mime[:jsonapi] if self.media_type.nil?
4141

4242
many = JSONAPI::Rails.is_collection?(resource, options[:is_collection])
4343
resource = [resource] unless many
@@ -90,7 +90,7 @@ def self.add_errors_renderer!
9090
# @return [NilClass]
9191
def self.add_renderer!
9292
ActionController::Renderers.add(:jsonapi) do |resource, options|
93-
self.content_type ||= Mime[:jsonapi]
93+
self.content_type = Mime[:jsonapi] if self.media_type.nil?
9494

9595
JSONAPI_METHODS_MAPPING.to_a[0..1].each do |opt, method_name|
9696
next unless respond_to?(method_name, true)

0 commit comments

Comments
 (0)