Skip to content

Commit

Permalink
Handle render.ams with nil serializer or adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
bf4 committed Mar 29, 2016
1 parent 84197e4 commit 6a60d45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/active_model/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class Serializer
include Links
include Meta
include Type
class Null < Serializer
def attributes; {}; end
def associations; {}; end
def serializable_hash; {}; end
end

# @param resource [ActiveRecord::Base, ActiveModelSerializers::Model]
# @return [ActiveModel::Serializer]
Expand Down
5 changes: 4 additions & 1 deletion lib/active_model_serializers/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ def notify_render(*)
end

def notify_render_payload
{ serializer: serializer, adapter: adapter }
{
serializer: serializer || ActiveModel::Serializer::Null,
adapter: adapter || ActiveModelSerializers::Adapter::Null,
}
end

private
Expand Down

0 comments on commit 6a60d45

Please sign in to comment.