Skip to content

Instantly share code, notes, and snippets.

@samnang
Created April 25, 2014 08:14
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 samnang/11281733 to your computer and use it in GitHub Desktop.
Save samnang/11281733 to your computer and use it in GitHub Desktop.
def json_for(target, options = {})
options[:root] = false
options[:scope] ||= current_user
options[:url_options] ||= url_options
serializer = options.delete(:serializer) || target.active_model_serializer
serializer.new(target, options).to_json
end
@samnang
Copy link
Author

samnang commented Apr 25, 2014

<body ng-controller="ApplicationController" ng-init="setCurrentUser(<%= json_for(current_user, serializer: UserInfoSerializer) %>)">

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