我有一个 Rails 应用程序,在这个特定页面上(使用 SSL)我有一个用于创建“帖子”的表单,然后是用于上传属于该帖子的图像的单独表单。
图像形式为:
<%= form_for Image.new, :html => {:multipart => true} do |g| %>
<%= g.text_field :whence, :id => "postWhence"%>
<%= g.file_field :image, :id => "postImage_file_field", multiple: true, name: "image[image]" %>
<%= g.file_field :image, :id =>"postLogo_file_field"%>
<% end %>
我见过人们添加:secure => true
and :protocol => 'https'
,但这似乎只有在表单的格式类似于
form_for @user, :url => user_path(:secure => true)
.
我之所以尝试这样做是因为当我部署到生产服务器时,图像上传突然不起作用,并且在检查日志时我看到:
Filter chain halted as :ensure_proper_protocol rendered or redirected
Completed 302 Found in 2ms (ActiveRecord: 0.0ms)" when I attempted to upload the image.