Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
404 views
in Technique[技术] by (71.8m points)

ruby on rails - Shrine::Error (storage :store isn't registered on ImageUploader)

The subject says it all.

I’m using shrine with a photos model.

When I upload file, the create action throws this error

Shrine::Error (storage :store isn't registered on ImageUploader)

I looked it up and everyone is saying to change the name of the shrine.rb to something like 01_shrine.rb so that it loads earlier.

This did not work for me. I have an image_uploader.rb in my models folder and a shrine.rb in config / initializers.

The weird thing is that after rails throws an error, when I navigate to photos route, the photo did in fact upload.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The problem might be with your old records. As i suspect, by default config was something like:

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

Then you uploaded file for test purposes and renamed initial "store" store

Shrine.storages = {
  new_cache: Shrine::Storage::FileSystem.new("public", prefix: "uploads/cache"), # temporary
  **new_store**: Shrine::Storage::FileSystem.new("public", prefix: "uploads"),       # permanent
}

Shrine tries to find the old "store" in your existing record and throws error


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...