Skip to content

Instantly share code, notes, and snippets.

@barsukov
Last active August 29, 2015 14:05
Show Gist options
  • Save barsukov/17809bcc1a727662e89a to your computer and use it in GitHub Desktop.
Save barsukov/17809bcc1a727662e89a to your computer and use it in GitHub Desktop.
Active model serializer pass parametrs like options
class LoLSerializer < ActiveModel::Serializer
...
hash["super_trooper"] = options[:super_trooper]
...
end
..
#Usage:
ActiveModel::ArraySerializer.new(ololol_collection,
each_serializer: LoLSerializer, super_trooper: params[:super_trooper]).to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment