undefined method `serializable_hash' for String

前端 未结 1 795
生来不讨喜
生来不讨喜 2021-02-13 03:07

i\'m trying to_json in the following way

 @own_events.as_json(:include => {:created_date => {},:attendees => {}, :user => {}, :start_times => {},         


        
相关标签:
1条回答
  • 2021-02-13 03:42

    :include is used to include associations in the json, usually has_many or belongs_to associations.

    To include methods like created_date, use methods:

    Such as:

    @own_events.as_json(include: [:attendees, :user, :start_times, :end_times], methods: :created_date )
    
    0 讨论(0)
提交回复
热议问题