Vlad Balanescu Vlad Balanescu - 1 year ago 114
Ruby Question

Download link on Paperclip Attachment in Rails_admin

I am using

gem together with
. My model looks like this:

class Product < ActiveRecord::Base
has_attached_file :asset,
:styles => {
:thumb => "100x100#",
:small => "150x150>",
:medium => "200x200" }
validates_attachment_content_type :asset, :content_type => /\Aimage\/.*\Z/

How can I include a download link into the
action? So that, on
every entry in the table will have a download link? I read through the documentation, but they don't seem to specify any of these features.


On my main index action which was routed here:
I used to do:

<%= link_to "Download", product.asset.url(:original, false) %>

Answer Source


Submission model:

class Submission < ActiveRecord::Base

  # Image attachment and validations
  has_attached_file :file,
    :url => "/files/:class/:attachment/:id/:style/:basename.:extension",
    :path => ":rails_root/public/files/:class/:attachment/:id/:style/:basename.:extension"

  validates_attachment_content_type :file, :content_type => 'application/pdf'

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download