To override your root nodes for ActiveModel serializers without a global config use the following. This makes a consistent API for clients regardless of model but still leaves your code flexible. # Controller render json: @liked, root: ‘data’   # Returns a collection like so. { "data" [{}, {}, {}] }

In this example we can see how to pass a block to a Struck for a default value. Course = Struct.new :title, :major, :location do def initialize(*) super self.location ||= ‘UCLA’ end end   course = Course.new("Machine Learning", ‘Comp Sci’) => #<struct Course title="Machine Learning", major=’Comp Sci’, location="UCLA">   course = Person.new("Machine Learning", ‘Comp Sci’, "UCSD") => #<struct Course name="Machine Learning", major=’Comp Sci’, location="UCSD">