Active_model_serializers: NoMethodError: undefined method `model_name' for Hash:Class

Created on 23 May 2017  路  1Comment  路  Source: rails-api/active_model_serializers

ActiveModelSerializers.config.adapter = :json

instead of using a serializer, for error_messages we do something like this

def render_error(resource, status = :unprocessable_entity)
  render json: { errors: resource.errors.full_messages } , status: status
end

or sometimes we simply do

render json: {status: "approved"}

all of those throw the error ' undefined method `model_name' for Hash:Class'
i can't find a workaround to bypass serializer lookup for certain actions.

how to workaround this? what are we doing wrong?

Most helpful comment

>All comments

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PratheepV picture PratheepV  路  4Comments

Andriykoo picture Andriykoo  路  5Comments

AlexCppns picture AlexCppns  路  5Comments

adamcrown picture adamcrown  路  4Comments

deependersingla picture deependersingla  路  4Comments