When using an API requested through ajax, the query returns a collection that is serialized into json before being sent back to the client. Each record in the collection has a photo URL assigned by Carrierwave. This seems like a standard process.
However, when checking in the Rails console, the full public URL of each photo in Google Cloud Storage is retrieved, whereas on the client-side response, only a partial URL like "uploads/..." is received from the array of objects. I need the complete URL, similar to what is displayed in the console, to be parsed and included in the returned JSON.
How can I achieve this?
controller.rb
def get_filtered
...
# query is performed
...
render json: filtered_properties.as_json
end
On the JavaScript side:
...
properties = response.data
properties[0].photos[0].url // => "uploads/property/photos/photo1.jpg"
Although in the rails console, I can see the complete public URL leading to my Google Cloud Storage folder.