You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had a weird bug happen to me today. After I added a include: [...] clause to my render statement, I notice one of my objects became a dump of the raw object json instead of using the serializer I specified on has_many.
I have a has_many :stuff, serializer: StuffSerializer.
It turned out that my stuff field wasn't included in the include: [...], which caused the framework to do a raw dump of the data. Adding stuff to include: [...] fixed the issue, but I believe this to be a bug.
Steps to reproduce
(e.g., detailed walkthrough, runnable script, example application)
class MySerializer < ActiveModel::Serializer
belongs_to :something, serializer: SomethingSerializer
has_many :stuff, serializer: StuffSerializer
def stuff
Stuff.all
end
end
# in the controller
render json: list, include: [:something], serializer: MySerializer
Environment
ActiveModelSerializers Version (commit ref if not on tag):
0.10.13
Expected behavior vs actual behavior
I had a weird bug happen to me today. After I added a
include: [...]
clause to myrender
statement, I notice one of my objects became a dump of the raw object json instead of using the serializer I specified onhas_many
.I have a
has_many :stuff, serializer: StuffSerializer
.It turned out that my
stuff
field wasn't included in theinclude: [...]
, which caused the framework to do a raw dump of the data. Addingstuff
toinclude: [...]
fixed the issue, but I believe this to be a bug.Steps to reproduce
(e.g., detailed walkthrough, runnable script, example application)
Environment
ActiveModelSerializers Version (commit ref if not on tag):
0.10.13
Output of
ruby -e "puts RUBY_DESCRIPTION"
:ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin22]
OS Type & Version:
Macos Sonoma 14.3.1 (23D60)
Integrated application and version (e.g., Rails, Grape, etc):
gem "rails", "~> 7.0.6"
Backtrace
(e.g., provide any applicable backtraces from your application)
N/A
Additonal helpful information
(e.g., Gemfile.lock, configurations, PR containing a failing test, git bisect results)
The text was updated successfully, but these errors were encountered: