Skip to content

Instantly share code, notes, and snippets.

@mtkd
Created September 15, 2012 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtkd/3728976 to your computer and use it in GitHub Desktop.
Save mtkd/3728976 to your computer and use it in GitHub Desktop.
ActiveModel::Serializer and :only
class FooSerializer < ActiveModel::Serializer
attributes :_id, :name
def attributes
h = super
h.select! { |x| options[:only].include? x } if options[:only]
h
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment