Conditional attributes with jsonapi-serializers throwing TypeError
问题 I am working on a Ruby on Rails project with ruby-2.6.0 and Rails 6. i am working on api part, i have used jsonapi-serializers gem in my app. I want to add conditional attribute in serializer. Controller: class OrderDetailsController < Api::V1::ApiApplicationController before_action :validate_token def show user = User.find_by_id(@user_id) order_details = user.order_details.where(id: params[:id])&.first render json: JSONAPI::Serializer.serialize(order_details, context: { order_detail: true })