2 errors prohibited this post from being saved:
-Video content type is invalid -Video is invalid
I'm trying to upload videos to my site locally in dev using the Paperclip Gem however, I either get a black screen with a play button that does not play the video or I get the above error message when uploading videos. I am using Rails 4.0.
Can someone please direct me in the right direction on how to get rid of this error and using the Paperclip Gem in order to successfully upload videos?
Model
class Post < ActiveRecord::Base
belongs_to :user
has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }
has_attached_file :video, :styles => {:mp4 => { :geometry => "300x300", :format => 'mp4' },:thumb => { :geometry => "150x150>", :format => 'jpg', :time => 5 }
}, :processors => [:ffmpeg]
validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
validates_attachment_content_type :video, :content_type => ["video/mp4", "video/mov", "video/mpeg","video/mpeg4", "video/AVI"]
validates :description, presence: true
validates :image, presence: false
validates :video, presence: false
end
Show.html
<div class="row">
<div class="col-md-offset-4 col-med-8">
<div class="panel panel-default">
<div class="panel-heading center">
<%= image_tag @post.image.url(:medium) %>
<%= video_tag @post.video.url(:medium), controls: true, type: "video/MOV" %>
</div>
<div class="panel-body">
<p><%= @post.description %></p>
<p><strong><%= @post.user.name if @post.user %></strong></p>
<% if @post.user == current_user %>
<%= link_to edit_post_path(@post) do %>
<span class="glyphicon glyphicon-edit"></span>
Edit
<% end %>
<% end %>
<%= link_to 'Back', posts_path %>
</div>
</div>
Migration
class AddAttachmentVideoToPosts < ActiveRecord::Migration
def self.up
change_table :posts do |t|
t.attachment :video
end
end
def self.down
drop_attached_file :posts, :video
end
end
Post Controller
def post_params
params.require(:post).permit(:description, :image, :video)
end
Config/enviroments/dev
scout::Application.configure do
Paperclip.options[:command_path] = "/usr/local/bin"
Here is the link to my other question regarding this one. Thank you in advance.