Rails Paperclip undefined method `validates_attachment '?

I get an error message from some validation code that I have in my model. My system uses paperclip to attach many files to a help article, and I know that I have paperclip installed because I can download files just without checking them.

Here is my model:

class HelpAttachment < ActiveRecord::Base

  belongs_to :help

  has_attached_file :attachment, 
                    :styles => { :medium => "300x300>",
                                 :thumb => "100x100>" }

  validates_attachment :attachment, :content_type => [ 'image/png', 'image/jpg', 'image/gif', "application/pdf", 
                                    'video/mpeg', 'video/quicktime', 'video/x-ms-asf', 'video/x-msvideo', 
                                    'video/x-flv' ]


end

And this is the error message that I get when I try to send a new attachment:

NoMethodError in HelpsController#create

undefined method `validates_attachment' for #<Class:0x00000005581498>

If I delete the validates_attachment line, everything will work, just checking the file will not.

I have a gem 'paperclip' in my gemfile and I am starting in development mode.

Any ideas?

+3
source share
1 answer

github " ". 3.0

validates :attachment, :attachment_content_type => { :content_type => ['image/png', 'image/jpg']}
+4

All Articles