Closed fmh closed 10 years ago
model.rb
validates :title,:story, presence: { message: "Must be given please" }, length: { in:6..20 } validates :author_id, presence: true validates :poster, attachment_presence: true validates :title, length:{in:6..20}
has_attached_file :poster, styles: { thumb: '10x10>', square: '200x200#', medium: '50x50>', pdf_preview: '600x600>'}, processors: [:thumbnail] validates_attachment :poster, :content_type => {:content_type => %w(image/jpeg image/jpg image/png application/pdf application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document)}, attachment_size: { less_than: 5.megabytes } has_attached_file :poster
belongs_to :author, required: false has_and_belongs_to_many :reviews
after_create :article_publishing after_update :article_update
Question? These are my Rails model validations, If i submit empty form data not saved in database.Here is the problem errors are also not showing,why??
This my code for Views errors for one field....... index.html.erb
<%= form.label @article.errors.messages[:story].first if @article.errors.messages[:story].any? %>
can any one give the answer, How to show the errors in View, How to rectify my problem........Thank you all
In my case it was working perfectly fine in my local dev machine but giving following error on production environment.
<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
I checked version of imagemagick on my machine it was ImageMagick 7.0.8-59
. I checked version on my production environment it was ImageMagick 6.9.4-7
. I was using dockerfile
to setup my production environment. I was using following line of code to install imagemagick in production env.
RUN apt-get update && apt-get -y install imagemagick && apt-get clean
even though my exceptions were that this command would install the latest version of imagemagick but it was installing every time ImageMagick 6.9.4-7
. #2223 states that processing of pdf
has been disabled by the imagemagick. I decided to update the version of imagemagick of production but I couldn't use the apt-get
because it was installing the wrong version. I decided to install it from source but installing from source doesn't install dependencies so i had to install them manually. This was my code in dockerfile
RUN apt-get install wget
RUN apt-get update -qq && apt-get install -y \
libmagickwand-dev \
libmagickcore-dev
RUN wget https://imagemagick.org/download/ImageMagick.tar.gz
RUN apt-get install -y build-essential checkinstall
RUN tar xf ImageMagick.tar.gz
RUN cd ImageMagick-7.0.8-64 && \
./configure && \
make && \
checkinstall && \
ldconfig && \
cd .. && \
rm -rf ImageMagick*
RUN apt-get update && apt-get -y install ghostscript && apt-get clean
the download url might change later in time.
Got to this thread with the same error
ActionView::Template::Error (Paperclip::Errors::NotIdentifiedByImageMagickError)
After some investigation, I found the problem in my default ImageMagick policies at /etc/ImageMagick/policy.xml
Since I was cropping images from Unsplash, they were rightfully considered downloaded via HTTP / HTTPS, while my policy.xml
had these lines among others:
<policy domain="coder" rights="none" pattern="HTTPS" />
<policy domain="coder" rights="none" pattern="HTTP" />
Thus, ImageMagick blew up on downloaded images while still handling direct uploads. Commenting these 2 lines out has resolved my problem. Hope this helps someone!
sudo apt-get install imagemagick && sudo apt-get install libmagick++-dev
This command solved my problem
Just leaving a comment here for fellow googlers in the future - we were getting an intermittent failure in production on PDF uploads (< 1%).
It appears that I was able to repro the error condition by password protecting the PDF, which caused the Paperclip::Errors::NotIdentifiedByImageMagickError to be raised 🤔
Mac OS X 10.9 ImageMagick 6.8.7 installed through brew , '/usr/local/bin/identify' Ruby 2 Rails 4 Paperclip 3.5.2 , cocaine 0.5.3
I tried everything but still not work !!!