Reputation: 864
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
ruby '2.1.2'
gem 'rails', '4.1.6'
gem 'activeadmin', github: 'gregbell/active_admin'
gem 'paperclip'
gem 'aws-sdk'
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
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
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
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
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.
Imagemagick does the resizing / image manipulation for Paperclip.
Upvotes: 0