Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Can upload file via console using paperclip 4.0

paperclip rails4 ruby2.0

  • Please log in to reply
1 reply to this topic

#1 Vell

Vell

    Dispatcher

  • Members
  • 42 posts
  • LocationWashington, DC

Posted 18 February 2014 - 06:01 PM

Hello all,

 

I am using rails 4 and attemting to create an attachments table using paperclip 4.0. Right now I am trying to write a test where I upload a file in the back end but I am not able to get this tow ork. My current error that I am getting is:

Paperclip::AdapterRegistry::NoHandlerError: No handler found for #<Pathname:/Users/lmcilwain/rails/employee_info/features/support/rails.png>

The way that I was attemping to upload this file is:

EmpAttachment.new(picture: Rails.root+'features/support/rails.png')

Here is what I have in my model:

has_attached_file :picture
validates_attachment_content_type :picture, :content_type => /\Aimage\/.*\Z/


#2 Vell

Vell

    Dispatcher

  • Members
  • 42 posts
  • LocationWashington, DC

Posted 20 February 2014 - 12:23 AM

Regarding this error. I forgot I needed to submit a file object in order for this to work.

EmpAttachment.new(picture: open("#{Rails.root}/features/support/rails.png"))

  • james likes this





Also tagged with one or more of these keywords: paperclip, rails4, ruby2.0

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users