0

Rails 4.2.5 and ruby 2.3.3p222

I am using Paperclip to upload files, if I upload pdf's the display works fine but I cant find a way to display word files correctly in the browser.

Model:

has_attached_file :document
validates_attachment :document, :content_type => { :content_type => %w(application/pdf application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document) }

In my form:

<%= f.input :document, as: :file %>

In my show:

<iframe src="<%= @article.document.url %>" style="height:800px;width:100%"></iframe>

Again, if its a pdf it shows perfectly, although if its a word file it just downloads the file instantly as soon as I load the page.

I think its the that I am using in the Show page but cant find any solution when searching on google. Anyone tried to do this or has any suggestion?

Thanks in advance.

Joao Quaresma
  • 41
  • 1
  • 7
  • 1
    I don't think you can render a *.doc file in the browser. There is an explanation [here](https://stackoverflow.com/a/27958186/5239030). – iGian May 02 '18 at 17:26
  • Thank you for your comment, looks like they used the Google Docs Viewer to show the doc, what is all I need, I tried but gives an error saying that the file cant be found. I believe that we would need to send this to google docs online before or something? This is what I have tried: – Joao Quaresma May 02 '18 at 18:55

0 Answers0