开发者

Is paperclip support rails3? how can i support upload pdf files only?

now i am trying to upload a pdf file to the server ,but i get nothing,when i try to get the url of the attached file,i got some missing.png file name. Is there some where i can set to tell the paperclip that i just want to upload pdf files but not pictures? great thanks... here is my class settings

============================================model file
class RdBenefit < ActiveRecord::Base
  belongs_to :reim_detail  
  has_attached_file :details
  validates_attachment_content_type :doc, :content_type => ['application/doc'] 
end

======================================schema
  create_table "rd_benefits", :force => true do |t|
    t.integer  "sequence"
    t.date     "reim_date"
    t.integer  "fee_time_span"
    t.integer  "people_count"
    t.decimal  "amount",               :precision => 10, :scale => 0
    t.integer  "reim_detail_id"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "details_file_name"
    t.string   "details_content_type"
    t.inte开发者_运维知识库ger  "details_file_size"
    t.datetime "details_updated_at"
  end


==========================gemfile
gem "paperclip"


=========================view file
<%= form_for @doc_head,:remote=>true,:html => { :multipart => true } do |f| %>


Paperclip works with Rails3.

If you want to limit your attachment just to PDF's, you should set up validation on your attachment like this:

validates_attachment_content_type :pdf, :content_type => ['application/pdf'] 


use

gem 'remotipart', '~> 1.2' 

gem if you are going to upload file via ajax


Your problem here is :remote => true. It seems you cannot upload files over an XHR request.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜