当前位置: 动力学知识库 > 问答 > 编程问答 >

activemodel - Use active model serializer with rails namespaces

问题描述:

I am in this situation,

in my controller I call:

render json: @customers_filtered, serializer: User::CustomerSerializer

My serializer:

class User::CustomerSerializer < ActiveModel::Serializer

attributes :id,:firstname

end

But when I call the controller's action, it gives me:

Unable to autoload constant CustomerSerializer, expected /var/www/qbvault/app/serializers/customer_serializer.rb to define it

If I cut the User:: from the serializer, it doesn't find the model where to read attributes from.

Is there a way to fix di behaviour? Can I set the model name on the serializer?

分享给朋友:
您可能感兴趣的文章:
随机阅读: