Vlad Balanescu Vlad Balanescu - 16 days ago 6
Ruby Question

Download link on Paperclip Attachment in Rails_admin

I am using

rails_admin
gem together with
Paperclip
. 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/
end


How can I include a download link into the
index
action? So that, on
admin/products
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.

[EDIT]

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

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

Answer

[SOLVED]

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'

end