Skip to content

Instantly share code, notes, and snippets.

@dobryakov
Last active November 25, 2015 13:32
Show Gist options
  • Save dobryakov/aa2b53f8e5064054f358 to your computer and use it in GitHub Desktop.
Save dobryakov/aa2b53f8e5064054f358 to your computer and use it in GitHub Desktop.
@items.to_json(:user => current_user)
attr_accessor :current_user
def serializable_hash(options={})
options = {} if options.nil?
self.current_user = options[:user]
options[:methods] ||= [ :participated_friends_ids ]
super(options)
end
def participated_friends_ids(user = self.current_user)
unless user.nil?
# do some work
else
[]
end
end
@dobryakov
Copy link
Author

Magic for personal serializing to json for each user separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment