/ / रेल्स पेपरलीक :: अडैप्टररेजिस्ट्री :: नोहैंडलर एरर - माणिक-ऑन-रेल्स, रूबी, रूबी-ऑन-रेल्स -४, पेपरक्लिप, एक्टीडमिन

रेल पेपरक्लिप :: एडाप्टर रजिस्ट्री :: NoHandlerError - रूबी-ऑन-रेल, रूबी, रूबी-ऑन-रेल -4, पेपरक्लिप, एक्टिवडमिन

त्रुटि

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

मेरे पास सक्रिय व्यवस्थापक के साथ एक रेल 4 ऐप है और अपने पोस्ट मॉडल पर एक छवि अपलोड करने की कोशिश कर रहा हूं, लेकिन मुझे उपरोक्त त्रुटि मिल रही है। यहाँ मेरा सेटअप है

Gemfile

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

/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" }

उत्तर:

उत्तर № 1 के लिए 6

तो इसका जवाब है:

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

जवाब के लिए 0 № 2

क्या आपके पास इमेजमैगिक स्थापित है?

ओएस एक्स पर अगर आपके पास होमब्रे है, तो यह आसान है brew install imagemagick। विंडोज़ के लिए, .exe प्राप्त करें।

http://www.imagemagick.org/

Imagemagick पेपरक्लिप के लिए आकार बदलने / छवि हेरफेर करता है।