我使用的是FileStack API和filepicker gem。根据文件(http://www.rubydoc.info/github/Ink/filepicker-rails/master/FilepickerRails/ApplicationHelper:filepicker_save_button)保存按钮采用选项散列。然而,当我实现它时,没有一个选项起作用,即save_as_name和服务都不起作用。
<%= filepicker_save_link "Save", a.title, "pdf", save_as_name: "exampleName", services: 'BOX' %>
我执行这个错误了吗?还是宝石有问题?
这是gem本身的问题。联系了一位FileStack工程师,这是他的建议,现在它起作用了。只需将其添加到正在使用的控制器辅助对象中即可。他们会将此问题通知维护gem的工程师。
def export_widget(text, url, mimetype, options, &block)
options[:data] ||= {}
container = options.delete(:container)
services = options.delete(:services)
save_as = options.delete(:save_as_name)
options[:data]['fp-url'] = url
options[:data]['fp-apikey'] = ::Rails.application.config.filepicker_rails.api_key
options[:data]['fp-mimetype'] = mimetype
options[:data]['fp-option-container'] = container if container
options[:data]['fp-option-services'] = Array(services).join(",") if services
options[:data]['fp-option-defaultSaveasName'] = save_as if save_as
block.call
end
end
end
来自工程师:"所以,也许你可以通过编辑应用程序助手来让它工作,它有fp选项服务,将其更改为fp服务,例如:
options[:data]['fp-services'] = Array(services).join(",") if services
这些选项需要以Ruby哈希的形式传递。例如,当使用此时
<%= filepicker_save_link "Save", a.title, "application/pdf", { save_as_name: "exampleName", services: 'BOX'} %>