当我尝试使用Simple Form gem上传视频时遇到麻烦。我为此使用activeStorage和本地存储。 我的表单如下:
= simple_form_for @film do |f|
= f.error_notification
= f.input :title,as: :string
= f.input :description,as: :string
= f.input :cover_img,as: :file
= f.input :film_link,as: :file,direct_upload: true
= f.button :submit
= link_to 'back',:back,class: 'btn btn-secondary'
我已按照https://edgeguides.rubyonrails.org/active_storage_overview.html的指示进行操作
因此,我在应用程序中包含了js和CSS文件。但这行不通。通过simple_form传递direct_upload: true
似乎有些麻烦。
我也找到了文章https://phase2online.com/blog/2018/10/03/easily-upload-files-with-active-storage-in-rails-5-2/,并从here提取了git repo
这将在您在_form上使用form_for时起作用。当我将表单更改为使用simple_form gem(而不是form_form使用simple_form_for)时,它将不起作用。
有人知道为什么这不起作用吗? 我使用ruby 2.6.3和Rails 5.2.3和simple_form(5.0.1)