2016年3月30日 星期三

Initialize the serializer

ActiveModel::ArraySerializer.new(Funding.all, each_serializer: FundingSerializer).to_json




For me I passed the view_context to the array serializer:
ActiveModel::ArraySerializer.new(your_array, each_serializer: YourSerializer, scope: self.view_context)

how to pass scope

https://github.com/rails-api/active_model_serializers/issues/510




沒有留言:

張貼留言