Dan Mitchell
Dan Mitchell

Reputation: 864

Rails Paperclip::AdapterRegistry::NoHandlerError

Error

Paperclip::AdapterRegistry::NoHandlerError at /admin/posts/1 No handler found for foo.png

I have a rails 4 app with Active Admin and im trying to upload an image to my Post model but I am getting the above error. Here is my setup

Gemfile

ruby '2.1.2'

gem 'rails', '4.1.6'
gem 'activeadmin', github: 'gregbell/active_admin'
gem 'paperclip'
gem 'aws-sdk'

Model

class Post < ActiveRecord::Base

  has_attached_file :image, styles: {
    thumb: '100x100>',
    square: '200x200#',
    medium: '300x300>'
  }
  validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/

end

Active Admin

permit_params :image

form do |f|
  f.inputs do
    f.input :image, as: :file, hint: (f.template.image_tag(f.object.image.url(:thumb)) if f.object.image?)
  end
  f.actions
end

/config/initializers/paperclip.rb

Paperclip::Attachment.default_options[:storage] = :s3
Paperclip::Attachment.default_options[:s3_host_name] = 's3-eu-west-1.amazonaws.com'
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'
Paperclip::Attachment.default_options[:s3_protocol] = 'http'
Paperclip::Attachment.default_options[:s3_credentials] = 
  { :bucket => 'foo-production',
    :access_key_id => 'XXXXXXXXXXXX',
    :secret_access_key => 'XXXXXXXXXXXXXXXXXXXXXX' }

Upvotes: 2

Views: 5421

Answers (2)

Dan Mitchell
Dan Mitchell

Reputation: 864

So this is the answer:

form :html => {:multipart => true} do |f|
  f.inputs do
    f.input :image, as: :file, hint: (f.template.image_tag(f.object.image.url(:thumb)) if f.object.image?)
  end
  f.actions
end

Upvotes: 6

erdostom
erdostom

Reputation: 387

Do you have imagemagick installed?

On OS X if you have homebrew, it's easy as brew install imagemagick. For windows, get the .exe.

http://www.imagemagick.org/

Imagemagick does the resizing / image manipulation for Paperclip.

Upvotes: 0

Related Questions