title: how to load and validate the video using paperclip-Rails
body: <p>please help solve the problem.</p>
  
  <p>using a paperclip I organized upload images. it works.</p>
  
  <p>Now I would like to organize a video upload. I changed this model:
  model:</p>
  
  <pre><code>class Video &lt; ActiveRecord::Base
    validates :title, presence: true
    validates :video, presence: true
  
    belongs_to :user
  
    has_attached_file   :video, 
                        :styles =&gt; { :medium =&gt; "300x300&gt;", :thumb =&gt; "100x100&gt;" }, 
                        :default_url =&gt; "/images/:style/missing.png"
  
    validates_attachment_content_type :video, :content_type =&gt; /\Avideo\/.*\Z/  
    validates_attachment_file_name :video, :matches =&gt; [/3gp\Z/, /mp4\Z/, /flv\Z/]  
  
   validate :file_size_validation, :if =&gt; "video?"  
  
    def file_size_validation
      errors[:video] &lt;&lt; "should be less than 2MB" if video.size.to_i &gt; 30.megabytes
    end  
  end
  </code></pre>
  
  <p>video controller:</p>
  
  <pre><code>def create
    @video = Video.new(video_params)   
  
    if @video.save
      @video.update_attributes(user: current_user)
  
      flash[:success] = :video_created
      redirect_to @video
    else
      flash.now[:error] = :user_not_created
      render 'new'
    end
  end
  </code></pre>
  
  <p>form:</p>
  
  <pre><code>&lt;%= form_for(@video) do |f| %&gt;
      &lt;%= f.text_field  :title %&gt;
      &lt;%= f.file_field  :video %&gt;
      &lt;%= f.submit %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>after attempting to upload the video I get the console the following error message:</p>
  
  <pre><code>Started POST "/videos" for 127.0.0.1 at 2015-07-23 14:17:32 +0300
  Processing by VideosController#create as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"RF3w8PzZ9LZ4pdqRPqRvHMQ+nYDL4om0YHAMlzTm8tf3iFmVmKxXSYKap3C0ogEnOkifm9i01oXs/rTX9zmtPA==", "video"=&gt;{"title"=&gt;"tty", "video"=&gt;#&lt;ActionDispatch::Http::UploadedFile:0x007f6624f10770 @tempfile=#&lt;Tempfile:/tmp/RackMultipart20150723-13428-u7s8i8.flv&gt;, @original_filename="mmm.flv", @content_type="video/x-flv", @headers="Content-Disposition: form-data; name=\"video[video]\"; filename=\"mmm.flv\"\r\nContent-Type: video/x-flv\r\n"&gt;}, "commit"=&gt;"Create Video"}
    User Load (0.3ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1  ORDER BY "users"."id" ASC LIMIT 1  [["id", 8]]
  Command :: file -b --mime '/tmp/c4efd5020cb49b9d3257ffa0fbccc0ae20150723-13428-6gn39i.flv'
  Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/c4efd5020cb49b9d3257ffa0fbccc0ae20150723-13428-1eailfd.flv[0]' 2&gt;/dev/null
  [paperclip] An error was received while processing: #&lt;Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError&gt;
  Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/c4efd5020cb49b9d3257ffa0fbccc0ae20150723-13428-1eailfd.flv[0]' 2&gt;/dev/null
  [paperclip] An error was received while processing: #&lt;Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError&gt;
     (0.2ms)  BEGIN
  Command :: file -b --mime '/tmp/c4efd5020cb49b9d3257ffa0fbccc0ae20150723-13428-khstwa.flv'
     (0.2ms)  ROLLBACK
  </code></pre>
  
  <p>on screen displays the following error message:</p>
  
  <blockquote>
    <p>Video Paperclip::Errors::NotIdentifiedByImageMagickError</p>
  </blockquote>
  
  <p>wherein imageMagik installed in my system:</p>
  
  <pre><code>sudo apt-get install imagemagick
  </code></pre>
  
  <p>db:</p>
  
  <pre><code>  create_table "videos", force: :cascade do |t|
      t.datetime "created_at",         null: false
      t.datetime "updated_at",         null: false
      t.string   "title"
      t.integer  "user_id"
      t.string   "video_file_size"
      t.string   "video_updated_at"
      t.string   "video_file_name"
      t.string   "video_content_type"
    end
  </code></pre>