
Untitled
By: a guest on
Aug 10th, 2012 | syntax:
None | size: 0.71 KB | hits: 10 | expires: Never
How to Upload a multipage PDF with Paperclip?
class Post < ActiveRecord::Base
belongs_to :Blogs
attr_accessible :content, :title, :pdf
has_attached_file :pdf,
:url => "/assets/products/:id/:style/:basename.:extension",
:path => ":rails_root/public/assets/products/:id/:style/:basename.:extension"
validates_attachment_content_type :pdf,
:content_type => [ 'application/pdf' ],
:message => "only pdf files are allowed"
end
<%= form_for ([@post]), :html => { :multipart => true } do |f| %>
<p>
<b> Name </b><br>
<%= f.file_field :pdf %>
</p>
<p>
<%= image_tag @post.pdf.url(:original) %>
</p>
<p>
<%= link_to 'My PDF', @post.pdf.url %>
</p>