Mike
Mike

Reputation: 159

Paperclip Viewing an Attachment Instead of Downloading

In my view, I have the lines

<%= link_to "View", employee_document.file.url, :target => "_blank" %> -
<%= link_to "Download", employee_document.file.url %>

I want view to open up a separate tab with the document in it. The download link works as it should, the view link unfortunately downloads the file.

Upvotes: 0

Views: 309

Answers (2)

Mahesh Sharma
Mahesh Sharma

Reputation: 191

def get_image
  send_file '/path/to.jpeg', :type => 'image/jpeg', :disposition => 'inline'
end

You can set the disposition to inline.

Upvotes: 1

Jarred Humphrey
Jarred Humphrey

Reputation: 648

This just depends on the file type of the attachment and the browser's settings for that particular file type. Some browsers will cause the file to be downloaded while others will open the file (if it knows how to and the settings allow for such).

Upvotes: 0

Related Questions