:include
parameter is expecting attributes from multiple models, and fails if it doesn't find them. Once I removed :include
, the JSON flowed freely.You also want to make sure that you are using bandwidth efficiently. This means only returning the attributes that you need to use. To include specific attributes in your JSON return data, you can use the
:only parameter to define only certain attributes to include in the data being sent. The callboxes model has 8 attributes; crime alerts has 13. By specifically transferring just the latitude and longitude, we reduce the size of the data by 81%.
No comments:
Post a Comment