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
# app/controllers/sessions_controller.rb
class SessionsController < DeviseTokenAuth::SessionsController
def render_create_success
render json: current_api_user, serializer: Api::V2::UserSerializer
end
end
But the method did not respect the serializer option; it seemed to call as_json directly on the model object (unless I'm mistaken). However, building the json separately before calling render actually uses the active_model_serializers UserSerializer:
# app/controllers/sessions_controller.rb
class SessionsController < DeviseTokenAuth::SessionsController
def render_create_success
data = Api::V2::UserSerializer.new(current_api_user).as_json
render json: data
end
end
Is this a bug?
The text was updated successfully, but these errors were encountered:
NOTE: Depending on your version of AMS, ActiveModel::SerializableResource might need to be replaced with ActiveModelSerializers::SerializableResource, but because of rails-api/active_model_serializers#1667 / #600, you're probably pinned to 0.10.0.rc4 like me, so the above is the version you want.
I wanted to override the JSON sent after successful sign in, so I did this:
But the method did not respect the
serializer
option; it seemed to callas_json
directly on the model object (unless I'm mistaken). However, building the json separately before callingrender
actually uses the active_model_serializersUserSerializer
:Is this a bug?
The text was updated successfully, but these errors were encountered: