Home Word upload and preview - Paperclip
Reply: 0

Word upload and preview - Paperclip

user1025
1#
user1025 Published in May 27, 2018, 3:36 am

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.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302837 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO