Rails 来自 selectbox 的精美上传器 select 文件夹

Rails fine-uploader select folder from selectbox

我尝试从 select 框中 select 文件夹,并将来自精细上传器的请求作为参数发送。但是发送空值。我的代码如下

    //haml codes
    - path = "#{Rails.root}/public/templates/custom/"
    - folders = Dir["#{path}*"]
    %select#selected_path.form-control{name: 'folder'}
      %option{disabled: "disabled", selected: "selected"} Select
      - folders.each do |folder|
        %option{value: "#{Rails.root + folder}"}
          - if File.directory? folder
            = folder

对于js代码

 $('#fine-uploader-gallery').fineUploader({
  template: 'qq-template-gallery',
  request: {
      endpoint: '/admin/files/upload',
      params: {
          authenticity_token: "<%= form_authenticity_token %>",
          // gecici path eklendi
          selected_path: $('#selected_path').change(function() {
            alert($('#selected_path option:selected').val());
            $('#selected_path option:selected').val()
           })

      }
  }
});

但是 selected_path 参数以上给我错误。从 js "selected_path"=>"[object HTMLSelectElement]" 错误返回,不是路径。我该如何解决这个问题? 提前谢谢你

添加到 haml,onchange

%select#selected_path.form-control{name: 'folder', :onchange => "go()"}

对于 js 也是如此

 $('#fine-uploader-gallery').fineUploader({
 template: 'qq-template-gallery',
 request: {
  endpoint: '/admin/files/upload',
  params: {
      authenticity_token: "<%= form_authenticity_token %>",
      // gecici path eklendi
      selected_path: function go() {
              var x = document.getElementById('selected_path');
              alert(x.value);
              return x.value;
      }
      }

  }
});

问题已解决。 我参考了 答案。