Forum: Ruby on Rails attachment_fu content_type problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4c2e3a5381459411d3ba43e7383505ed?d=identicon&s=25 Mark Studebaker (mstudebaker)
on 2007-04-27 23:59
(Received via mailing list)
Hi all....

Admittedly I'm new to Rails and trying to find my way but I'm having
an issue with uploading documents with attachment_fu.

I have a form where I'm uploading multiple attachments (using AJAX to
add file_filed_tags).  That seems to work pretty well.  The problem is
I can't seem to get the content_type to work as I would expect.  For
example, if I use this:

has_attachment :content_type => ['application/pdf', 'application/
msword', 'text/plain']

I would expect I can upload .pdf, .doc and .txt files but I get and
Document is invalid error (document is the name of my model)  I have
played around with different content_types but I can't seem to get
consistent results.

Thanks for any help.

- Mark

Here is the document model

class Document < ActiveRecord::Base
  belongs_to  :tournament, :polymorphic => true

  has_attachment :content_type => ['application/pdf', 'application/
msword', 'text/plain'],
                 :storage => :file_system,
                 :max_size => 1.megabyte

  validates_as_attachment

end
This topic is locked and can not be replied to.