OrestF / readymade

MIT License
9 stars 4 forks source link

Update collection_response #5

Closed OrestF closed 1 year ago

OrestF commented 2 years ago
  def collection_response(collection, *args)
    options = args.extract_options!

    render_json(
      {
        (options.delete(:root).presence || :items) => serialize_collection(paginate(collection, options), options),
        count: collection.count
      },
      options[:status] || :ok
    )
  end