Created
          October 23, 2014 20:13 
        
      - 
      
- 
        Save shunchu/6d229a9ce07b5e5ccfa9 to your computer and use it in GitHub Desktop. 
    Add attributes to JBuilder collections
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # this adds an additional `user_ids` array to each of the `organizations` collection | |
| json.organizations do |json| | |
| json.array! @organizations do |org| | |
| json.merge! org.attributes | |
| json.user_ids org.users.pluck(:id) | |
| end | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Or more simply, use the
embed :ids, include: truesyntax...