好的,所以我尝试了一段时间,我无法让它发挥作用。所以我开始新的,仍然在努力解决这个问题。我上传图片没问题。但由于某种原因,我在尝试上传视频时遇到错误。我安装了ffmpeg并安装了最新的回形针av-transcoder。
这是我的帖子模型
class Post < ActiveRecord::Base
belongs_to :user
has_attached_file :video, styles: {
:medium => {
:geometry => "640x480",
:format => 'mp4'
},
:thumb => { :geometry => "160x120", :format => 'jpeg', :time => 10}
}, :processors => [:transcoder]
validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/
end
这是我的帖子控制器
def index
@posts = Post.all.order("created_at DESC")
end
def show
end
def new
@post = current_user.posts.build
end
def edit
end
def create
@post = current_user.posts.build(post_params)
if @post.save
redirect_to @post, notice: 'Post was successfully created.'
else
render :new
end
end
def update
if @post.update(post_params)
redirect_to @post, notice: 'Post was successfully updated.'
else
render :edit
end
end
def destroy
@post.destroy
redirect_to posts_url
end
private
# Use callbacks to share common setup or constraints between actions.
def set_post
@post = Post.find_by(id: params[:id])
end
def correct_user
@post = current_user.posts.find_by(id: params[:id])
redirect_to posts_path, notice: "Not authorized to edit this post" if @post.nil?
end
# Never trust parameters from the scary internet, only allow the white list through.
def post_params
params.require(:post).permit(:description, :image, :video)
end
def bscenes_params
params.require(:post).permit(:video)
end
end
这是我在节目页面上使用的标签
<%= video_tag bscene.video.url(:medium), controls: true, style: "max-width: 100%;" %>
我一步一步地按照这个网站上的步骤进行操作 http://alloffices.io/posts/heroku-s3-paperclip-av-transcoder-for-video-uploads
不知道为什么我会得到NamError。任何帮助都会有很多帮助
当我拿走&#34; bscene&#34;从标签和控制器我然后在上传时得到它。