active_model_serializers icon indicating copy to clipboard operation
active_model_serializers copied to clipboard

Serializers returning reference String instead of json

Open austinh opened this issue 7 years ago • 6 comments

Expected behavior vs actual behavior

Recently upgraded from Rails 4.2 to Rails 5. I am on active_model_serializers 0.8.4 All serializers are returning a reference string instead of calling as_json automatically.

Steps to reproduce

(e.g., detailed walkthrough, runnable script, example application)

location_data = LocationData.find(params[:id])
data = LocationDataSerializer.new(location_data)
render json: data

response is:

"#<LocationDataSerializer:0x00007fa7fcc587c0>"

This is occuring for all of my serializers since the upgrade.

Environment

ActiveModelSerializers Version (commit ref if not on tag): 0.8.4

Output of ruby -e "puts RUBY_DESCRIPTION": ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]

OS Type & Version: Mac OS X 10.13.4

Integrated application and version (e.g., Rails, Grape, etc): Rails 5.1

Backtrace

(e.g., provide any applicable backtraces from your application)

Additonal helpful information

(e.g., Gemfile.lock, configurations, PR containing a failing test, git bisect results)

austinh avatar May 01 '18 21:05 austinh

it's working fine on Rails 5.2.0 I just tried to reproduce it, you can pull the code here and open http://localhost:3000/users/1

output: image

saiqulhaq avatar May 08 '18 11:05 saiqulhaq

@austinh Any progress?

stefanahman avatar Nov 01 '18 16:11 stefanahman

It was because of oj 3.0

austinh avatar Nov 01 '18 16:11 austinh

Alright thanks! Did you end up removing oj or could you figure out a workaround?

stefanahman avatar Nov 01 '18 16:11 stefanahman

@austinh bug report in oj?

bf4 avatar Nov 01 '18 17:11 bf4

@austinh @bf4 Is it possible to have AMS use oj? What changes did you make to make that happen?

oyeanuj avatar Feb 14 '20 06:02 oyeanuj