You can pass values to an activemodel serializer using the @options object like this:
class Api::CategoriesController < ApplicationController
respond_to :json
def index
respond_with Category.where("name ==? AND content_counter >?", params[:name], params[:counter].to_i),
counter_value: params[:counter]
end
end
class CategorySerializer < ActiveModel::Serializer
attributes :id, :name, :content_counter
has_many :chapters
def chapters
object.chapters.active.with_counter(@options[:counter_value])
end
end