Just to clarify, I am trying to return images, that I have stored using active storage on my machine, through the localhost for development testing purposes. I am not trying to render images from localhost unto the internet.
So I have a model that has a has_one_attached relation to an image, called sample.
meal.rb:
include Rails.application.routes.url_helpers
has_one_attached :sample
def get_sample_url
url_for(self.sample)
end
So I use the get_sample_url, above, to get the images. It has been returning a path and I just assumed that it was working and have built my entire API using similar code and getting similar links. But when I put the link in the browser, it doesn't return anything.
The link returned is http://localhost:3001/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--c83eba36bfec0607652b47d857104d3cf9e88009/cute%20owl.jpg
I want to know: Is the ideal way to return images from a Rails API? Why the link is not returning my images?