Mgcs  
                
                  
                    2021 年3 月 18 日 02:12
                   
                  1 
               
             
            
              Hi!
I’m trying to figure how to add more info to created_by in a GET request to a topic ID.
"created_by": {
  "id": 1,
  "username": "Name",
  "name": "Name",
  "avatar_template": "/user_avatar_url"
}
If I wanted to add other details, such as likes_give, likes_received, created_at, and other relevant info from the topic OP, how would I do that?
I was looking at add_to_serializer and I’ve tried doing something like this, which fails and breaks every page:
#plugin.rb
after_initialize do
  add_to_serializer(:basic_user, :created_at) do
    object.created_at
  end
end
Thanks!
             
            
              4 个赞 
            
            
           
          
            
              
                Mgcs  
              
                  
                    2021 年3 月 22 日 03:22
                   
                  2 
               
             
            
              Bumping this 
             
            
              
            
           
          
            
              
                sam  
              
                  
                    2021 年3 月 22 日 03:49
                   
                  3 
               
             
            
              probably cause it is not being selected, this is pretty complicated patch you are after, since this is for pay I think marketplace 
             
            
              4 个赞 
            
            
           
          
            
              
                fzngagan  
              
                  
                    2021 年3 月 22 日 07:37
                   
                  4 
               
             
            
              
Cheers from Pavilion 
             
            
              5 个赞 
            
            
           
          
            
              
                fzngagan  
              
                  
                    2021 年4 月 8 日 05:54
                   
                  5 
               
             
            
              This task was completed and paid for promptly. Was nice working with @Mgcs 
             
            
              6 个赞 
            
            
           
          
            
              
                system  
              
                  
                    2021 年5 月 8 日 05:55
                   
                  6 
               
             
            
              This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.