-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to pass options to serializer when using ActiveModelSerializers #141
Comments
@rbhitchcock I'm looking for this exact functionality myself. Have you tried to monkeypatch this and see if your concept works? |
@SirRawlins Yes, I am using the following initializer... # frozen_string_literal: true
module RocketPants
module Respondable
extend ActiveSupport::Concern
SerializerWrapper.class_eval do
# We need to pass serialiation options to our serializer, so let's modify the method
# definition. Issue opened on Github: (https://github.com/Sutto/rocket_pants/issues/141)
def serializable_hash(options = {})
instance = serializer.new(object, options)
if instance.respond_to?(:serializable_hash)
instance.serializable_hash options
else
instance.as_json options
end
end
end
end
end |
Sweet. Thanks Blake - I will drop that in and see how I get on.
|
ActiveModelSerializer allows for options to be passed to the serializer from the controller. RocketPants does not seem to support this at this time. If it does, could you please point me to instructions on how to do it?
It seems like the fix for this would be to update this line (
rocket_pants/lib/rocket_pants/controller/respondable.rb
Line 10 in bddc27a
options
variable to#serializable_hash
.I would be happy to make this change and submit a PR if that is the proper fix for this issue.
The text was updated successfully, but these errors were encountered: