Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在没有模型的情况下,如何在Rails中使用carrierwave?_Ruby On Rails_Carrierwave - Fatal编程技术网

Ruby on rails 在没有模型的情况下,如何在Rails中使用carrierwave?

Ruby on rails 在没有模型的情况下,如何在Rails中使用carrierwave?,ruby-on-rails,carrierwave,Ruby On Rails,Carrierwave,我只是想要一个表单,其中用户选择一个图像并将其提交给AWS S3 这是我的表格所在的页面 <%= form_tag('process', multipart: true) do %> <p> <label>My Image</label> <%= file_field :AssetImage %> <%= submit_tag "Send!" %> </p> <% end %

我只是想要一个表单,其中用户选择一个图像并将其提交给AWS S3

这是我的表格所在的页面

<%= form_tag('process', multipart: true) do %>
  <p>
    <label>My Image</label>
    <%= file_field :AssetImage %>
    <%= submit_tag "Send!" %>
  </p>
<% end %>

这是我的配置,在上传程序中我有存储:fog set。我不明白!!我不想把它和任何事情联系起来。。我只想上传它

你在使用fog gem吗?所以你会上传,然后你就不知道文件关联到了什么?为什么不呢,但至少创建一个上传模型一旦上传到S3,我需要的就是它的URL,这样我就可以将它提交给我正在使用的API。是的,我有雾宝石installed@user7954我不认为这是可能的,我建议直接使用Fog gem来实现同样的效果,而不使用carrierwave
CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS',                        # required
    :aws_access_key_id      => 'asdf',                        # required
    :aws_secret_access_key  => 'asdf',                            # required
    :host                   => 'https://s3.amazonaws.com',             # optional, defaults to nil
  }
  config.fog_directory  = 'AssetImage'                     # required
  config.fog_public     = true                                   # optional, defaults to     true
  config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}
end