active_model_serializers
active_model_serializers copied to clipboard
ActiveModel::Serializer implementation and Rails hooks
I have 2 models: `Profile` and `Public::Profile` and 2 serializers: * Api::Platform::Carmen::V1::ProfileSerializer * Api::Platform::Carmen::V1::Public::ProfileSerializer The first `Profile` could have many `Public::Profiles` so in the first serializer we have `has_many :public_profiles`....
When I use like below ``` render json: users, root: "users", meta: {content: "10"}, meta_key: 'message', adapter: :json ``` I get response as ``` users: [ { id: 1, name:...
Full credit to @brucec5 for discovering this functionality. #### Purpose `#belongs_to` docs were a little slim, and it took us a long time to realize that we could use this...
#### Expected behavior vs actual behavior If I have an object: cat = Cat.find_by_name('fluffy') and assume that I can do: cat.paws.last.claws.count => 5 cat.paws.first.claws.count => 4 ... If my controller...
I understand that AMS caches objects individually. And it seems to work great. Here is my serializer - ``` ruby class ViewerSerializer < ActiveModel::Serializer cache key: 'viewer' attributes :id, :name,...
We use JSON API and have a use case when we need to provide the total_count and some other custom meta information globally. Providing this as `meta:` option from each...
The following controller and serializer cause all specified associations to be preloaded: ```ruby class ProfileSerializer < ApplicationSerializer has_many :primary_conditions has_many :member_roles has_many :owned_sites has_many :tags has_many :award_nominee_awards has_many :award_nominees has_many...
I have the following serializer: ```ruby class ProfileSerializer < ApplicationSerializer attributes :id has_one :primary_address end ``` Serializer for `ProfileAddress` (`primary_addrress`) is missing at the moment. The controller is as simple...
#### Expected behavior vs actual behavior In our serializer we have the following code (mildly streamlined for clarity). The `last_sale` relation does not exist on the main model but is...
## Expected behaviour vs actual behaviour #### Expected The cache is invalidated when a record is updated in Rails app running 5.1 or higher versions of the gem with the...