Ruby on rails 在rails网站上传视频
我试图让我的用户在我的网站上上传视频(尚未部署,在本地测试)。我将其设置为,如果“用户信息”被保存,它将把他们带到“根路径”,即主页。如果未保存用户信息,它将再次呈现表单。在我添加视频上传功能之前,所有的信息都保存了下来,一切都很好,但是在添加了该功能之后,由于信息没有保存,它会一次又一次地呈现相同的表单。我如何检查出了什么问题?命令行显示以下错误: 用户信息表单部分: ` `Ruby on rails 在rails网站上传视频,ruby-on-rails,video,devise,ffmpeg,paperclip,Ruby On Rails,Video,Devise,Ffmpeg,Paperclip,我试图让我的用户在我的网站上上传视频(尚未部署,在本地测试)。我将其设置为,如果“用户信息”被保存,它将把他们带到“根路径”,即主页。如果未保存用户信息,它将再次呈现表单。在我添加视频上传功能之前,所有的信息都保存了下来,一切都很好,但是在添加了该功能之后,由于信息没有保存,它会一次又一次地呈现相同的表单。我如何检查出了什么问题?命令行显示以下错误: 用户信息表单部分: ` ` 我还安装了回形针和ffmpeg。当我说已安装时,实际上就是这样。我不确定我是否必须以任何方式操纵回形针或ffmpeg,
我还安装了回形针和ffmpeg。当我说已安装时,实际上就是这样。我不确定我是否必须以任何方式操纵回形针或ffmpeg,以使其与视频一起工作,我只是安装了它们,没有做任何其他事情。过去两天我一直在拔头发。非常感谢您的帮助。向控制器添加
放置@userinfo.errors。完整消息
,并报告结果。您说您正在使用designe,但我在您的用户
模型中没有看到任何designe代码。添加文件更改并删除图像。这对你没用,没有验证信息对我们没用。为什么所有空白代码都在控制器代码中?为什么你的大部分问题不是关于回形针的?你说你所做的只是“安装”,我想你的意思是添加gem和bundle以及一些基本用法?你试过什么?您的资源、参考资料或文章是什么?@fbelanger请让我知道我可以提供哪些其他信息以获得解决方案。非常感谢@fbelanger嘿,伙计,你在用户模型中看不到任何Desive代码的原因是因为用户模型与Desive没有关联。我有一个叫做usermain的不同模型,它与designe关联。用户模型只处理诸如姓名、学校、gpa等用户信息。。。等等控制器中的空函数是因为我稍后将向其添加内容。整个问题不是关于回形针的原因是因为我不知道回形针是否是问题所在,这就是我首先问这个问题的原因。因为我不知道是什么导致了这个问题
<%= simple_form_for @userinfo do |f| %>
<%= f.input :name, label: 'Full name', error: 'Full name is mandatory' %>
<%= f.input :username, label: 'Username', error: 'Username is mandatory, please specify one' %>
<%= f.input :school, label: 'Name of college' %>
<%= f.input :gpa, label: 'Enter GPA' %>
<%= f.input :email, label: 'Enter email address' %>
<%= f.input :number, label: 'Phone number' %>
<%= f.file_field :video %>
<%= f.button :submit %>
<% end %>
class UsersController < ApplicationController
def index
end
def show
end
def new
@userinfo = User.new
end
def create
@userinfo = User.new(user_params)
if @userinfo.save
redirect_to root_path
else
render 'new'
end
end
def edit
end
def update
end
def destroy
end
private
def user_params
params.require(:user).permit(:name, :username, :email, :number, :school, :gpa, :major, :video)
end
end
class User < ActiveRecord::Base
belongs_to :usermain
has_attached_file :video, styles: {:video_show => {:geometry => "640x480",:format => 'mp4'},:video_index => { :geometry => "160x120", :format => 'jpeg', :time => 10}}, :processors => [:transcoder]
validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/
end
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :username
t.string :email
t.string :number
t.string :school
t.string :gpa
t.string :major
t.timestamps null: false
end
end
end
class AddAttachmentVideoToUsers < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.attachment :video
end
end
def self.down
remove_attachment :users, :video
end
end