Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.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 如何在神社中使用上传端点插件?_Ruby On Rails_Ruby_Rubygems_Shrine - Fatal编程技术网

Ruby on rails 如何在神社中使用上传端点插件?

Ruby on rails 如何在神社中使用上传端点插件?,ruby-on-rails,ruby,rubygems,shrine,Ruby On Rails,Ruby,Rubygems,Shrine,我想用神社的宝石,我读了一个,然后我指的是, 首先,我复制了示例代码,但我碰巧 ActionController::RoutingError (No route matches [GET] " /uploads/cache/47eee6dc368f20db1e26fa5176552136.jpg"): 我认为这个错误我无法发送正确的路径,我没有解决这个错误,即我没有使用Upload Endpoint插件,我可以发送Post请求,但不能使用get请求 有人教我如何在神殿里

我想用神社的宝石,我读了一个,然后我指的是, 首先,我复制了示例代码,但我碰巧

 ActionController::RoutingError (No route matches [GET] " 
/uploads/cache/47eee6dc368f20db1e26fa5176552136.jpg"):
我认为这个错误我无法发送正确的路径,我没有解决这个错误,即我没有使用Upload Endpoint插件,我可以发送Post请求,但不能使用get请求

有人教我如何在神殿里使用get请求吗

form.html.erb:

<div class ="container">
 <div class ="row">
 <%= form_with model: @photo, url:   photos_new_path,local: true do |f| %>

  <div class="form-group">

  <%= f.label :image %>

  <%= f.hidden_field :image, value: @photo.cached_image_data, class: "upload-data" %>

  <%= f.file_field :image, accept: ImageUploader::ALLOWED_TYPES.join(","),
 data: {
  upload_server: "upload_server",
  preview_element: "preview-photo",
  upload_result_element: "preview-photo-upload-result",
 }%>

  <div class="image-preview">
  <!-- static link to the thumbnail generated on attachment -->
  <%= image_tag @photo.image_url.to_s,
  width: 300,
  class: "img-thumbnail file-upload-preview",
  id: "preview-photo" %>
 </div>

 </div>

 <%= f.submit "create", class: "btn btn-primary" %>

<% end %>
</div>
Siline.rb的插件:

require "shrine"
require "shrine/storage/file_system"




Shrine.storages = {
 cache: Shrine::Storage::FileSystem.new("app/assets/images", prefix: "uploads/cache"), # temporary
 store: Shrine::Storage::FileSystem.new("app/assets/images", prefix: "uploads"),       # permanent
}


Shrine.plugin :pretty_location
Shrine.plugin :determine_mime_type, analyzer: :marcel


Shrine.plugin :activerecord           # loads Active Record integration
Shrine.plugin :cached_attachment_data # for retaining the cached file across form redisplays
Shrine.plugin :restore_cached_data # re-extract metadata when attaching a cached file

Shrine.plugin :validation_helpers


Shrine.plugin :derivatives
Shrine.plugin :derivation_endpoint, secret_key: "secret", expires_in: 10

Shrine.plugin :upload_endpoint, url: true
Shrine.plugin :default_url


 Shrine.plugin :backgrounding
Image_uploader.rb插件:

plugin :store_dimensions, analyzer: :ruby_vips, log_subscriber: nil
plugin :derivatives

plugin :derivation_endpoint, prefix: "derivations/image"
plugin :presign_endpoint
我用console.log检查了路径,因此response.uploadURL是

/uploads/cache/47eee6dc368f20db1e26fa5176552136.jpg
/uploads/cache/47eee6dc368f20db1e26fa5176552136.jpg