ruby-on-railspaperclipdocumentviewergoogle-docs-api

Where's my Paperclip doc? Finding the right path


I have a site that saves user documents and I want to use Paperclip to display them using Google Docs Viewer (https://drive.googleblog.com/2009/09/view-online-files-using-google-docs.html).

Paperclip is working. For instance, I have a file saved at: 127.0.0.1:3000/assets/resumes/51/original/myfile.pdf

I want to display that through the viewer embedded in my site. This is my code (in HAML):

%iframe{:src=>"http://docs.google.com/viewer?url=http%3A%2F%2F127.0.0.1:3000/#{@user.file.url}&embedded=true"}

Is the problem just the fact that I haven't got the site up and running on a public server yet, or is something wrong with my code? (When I paste the url straight into my browser without the viewer stuff I do see the file.)


Solution

  • Your assumption is correct. It is not working because your application is not in a public environment and Google Docs has no way of accessing your PDFs through your localhost address.