Hi I’m currently making an app for users to upload pics. I’m trying to add Amazon S3 in preparation to deploy my app. I’m not getting any error, but after trying to set up Amazon S3 my pics aren’t uploading properly. The pics are uploading properly onto Amazon, not in my database so that when I upload the pics and try to loop through them in the views to show them, nothing shows. Can anyone assist me?
Just as a sidenote, I’m using Paperclip + jQuery file upload (for multiple pic uploads) + Amazon S3 + a s3_direct_upload gem (https://github.com/WayneHoover/s3_direct_upload)
config routes (notice that pics is nested in albums and users) no issue here
Pholder::Application.routes.draw do
resources :users do
resources :friends
resources :albums do
resources :photos
end
end
end
users/show.html.erb (the page that is supposed to show my uploaded pics, no new pics are showing up even after my uploads)
<% @user.albums.each do |album| %>
<div class="albumthumb">
<%= link_to image_tag(!album.photos.empty? ? album.photos.first.avatar.url(:medium) : ("questionmark.png"), :size => "150x150"), user_album_path(@user, album) %>
<br>
<%= album.name %>
</div>
<% end %>
photos/new.html.erb (issue here as well)
#my new uploader that works with amazon s3, but doesn't seem to be storing the pics in my database
<%= s3_uploader_form post: user_album_photos_path, as: "photo[avatar]", id: "myS3Uploader" do %>
<%= file_field_tag :file, multiple: true %>
<% end %>
#this is my old upload form that worked fine when uploading pics to my local public directory.
#
#<% provide(:title, "Upload pictures") %>
#
#<%= form_for([@user, @album, @photo], :html => { :multipart => true }) do |f| %>
#
#<%= f.file_field :avatar, multiple: true, name: "photo[avatar]" %>
<div id="pics">
<%= render :partial => "photo", :collection => @photos %>
</div>
<script id="template-upload" type="text/x-tmpl">
<div class="upload">
{%=o.name%}
<div class="progress"><div class="bar" style="width: 0%"></div></div>
</div>
</script>
Here’s my code on github: https://github.com/EdmundMai/railstest/blob/master/app/views/photos/new.html.erb
Let me know if you need me to upload any more code. Please help!
JQuery file upload just uploads the files to Amazon S3: it doesn’t add the required Paperclip records to the database. To do that, you need to do a few more steps. See the jquery-fileupload-rails-paperclip-example or jQuery File Upload v4 for Rails 3.