【发布时间】:2023-07-06 05:54:02
【问题描述】:
我遇到了与this 问题类似的问题,只是我根本无法修改路径。
我正在使用 Spree 2.2,它使用回形针 3.4.2
我正在尝试修改回形针默认设置以更改图像路径。所有其他配置都在工作。
Myapp::Application.configure do
config.paperclip_defaults = {
:storage => :s3,
:s3_protocol => 'https',
:s3_host_name => "s3-eu-west-1.amazonaws.com",
:path => ":rails_root/public/:attachment/:id/:style/:basename.:extension",
:url => "/:attachment/:id/:style/:basename.:extension",
:s3_credentials => {
:bucket => 'xxx',
:access_key_id => "xxx",
:secret_access_key => "xxx"
}
}
end
但是使用这段代码,URL 是这样的:
https://s3-eu-west-1.amazonaws.com/bucketname/home/username/path/to/project/public/spree/products/24/original/ror_baseball.jpeg?1390110939
我已尝试将以下内容添加到该配置块:
config.attachment_path = '/spree/products/:id/:style/:basename.:extension'
我也尝试将以下内容添加到 config/initializers/paperclip.rb
Paperclip::Attachment.default_options[:url] = "/:attachment/:id/:style/:basename.:extension"
Paperclip::Attachment.default_options[:path] = ":rails_root/public/:attachment/:id/:style/:basename.:extension"
也试过了:
Paperclip::Attachment.default_options.merge!(
:path => ":rails_root/public/:attachment/:id/:style/:basename.:extension",
:url => "/:attachment/:id/:style/:basename.:extension"
)
有什么想法吗?
【问题讨论】:
标签: ruby-on-rails-4 paperclip spree