# Ruby S3 URL helper

**URL:** <https://meta.discourse.org/t/ruby-s3-url-helper/51923>\
**Category:** Support\
**Created:** [October 23, 2016, 12:59pm UTC](https://meta.discourse.org/t/ruby-s3-url-helper/51923 "2016-10-23T12:59:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![arrancscott](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arrancscott/32/50191_2.png) [@arrancscott](https://meta.discourse.org/u/arrancscott)\
**Post date:** [October 23, 2016, 12:59pm UTC](https://meta.discourse.org/t/ruby-s3-url-helper/51923/1 "2016-10-23T12:59:29Z")

</div>

Is there a way to get the URL on the Ruby side for the files uploaded to S3?

I have a partial that I’m pulling in with ajax that loops through a load of filenames, something like the following.

```
filenames.each do |filename|
  <%= image_tag filename %>
end

```

The filename is an image that will show in a slideshow/carousel, these images are uploaded to S3 and I want to get the full path to each image on S3.

I’ve traced this through and have seen how this is done on the front-end in the Ember app but I specifically want to get this on the Ruby side.

Cheers

---

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [October 24, 2016, 9:38am UTC](https://meta.discourse.org/t/ruby-s3-url-helper/51923/2 "2016-10-24T09:38:04Z")

</div>

How are you generating `filenames`?

---

<div class="post-metadata">

**Author:** ![arrancscott](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arrancscott/32/50191_2.png) [@arrancscott](https://meta.discourse.org/u/arrancscott)\
**Post date:** [October 24, 2016, 10:55am UTC](https://meta.discourse.org/t/ruby-s3-url-helper/51923/3 "2016-10-24T10:55:10Z")

</div>

`filenames` is a table, belonging to `User`.

The `filenames` table stores filenames for images uploaded to a users slideshow.

I’ve managed to solve this by adding an `upload_id` column to my table, and when creating the upload with `Upload.create_for` I set the upload\_id manually in the `filenames` table. This way I can find the upload using the `Upload.find_by` method and get the URL for the upload.

Seems to work ok, happy to be told if there will be an issue doing it this way.

---

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [October 24, 2016, 10:56am UTC](https://meta.discourse.org/t/ruby-s3-url-helper/51923/4 "2016-10-24T10:56:05Z")

</div>

> [@arrancscott](#):
>
> I’ve managed to solve this by adding an `upload_id` column to my table, and when creating the upload with `Upload.create_for` I set the `upload_id` manually in the filenames table.

That’s the way to go 👍

---

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [October 24, 2016, 10:56am UTC](https://meta.discourse.org/t/ruby-s3-url-helper/51923/5 "2016-10-24T10:56:11Z")

</div>


