【发布时间】:2015-07-10 08:42:56
【问题描述】:
我尝试在网上阅读很多内容,但没有任何帮助。所以需要一个具体的答案。如何配置 S3 以使用 Spree? 我正在使用 Spree 3.0.1 和 Rails 4.2.1。
我有 spree.rb 作为:
Spree.config do |config|
# Example:
# Uncomment to override the default site name.
# config.site_name = "Gazella Running Costumes"
# config.logo = "store/rungazella.png"
#S3 configuration
if Rails.env.production? then
#production. Store images on S3.
# development will default to local storage
attachment_config = {
s3_credentials: {
access_key_id: ENV["S3_KEY"],
secret_access_key: ENV["S3_SECRET"],
bucket: ENV["S3_BUCKET"],
},
storage: :s3,
s3_headers: { "Cache-Control" => "max-age=31557600" },
s3_protocol: "https",
bucket: ENV["S3_BUCKET"],
path: ":rails_root/public/:class/:attachment/:id/:style/:basename.:extension",
default_url: "/:class/:attachment/:id/:style/:basename.:extension",
default_style: "product",
}
attachment_config.each do |key, value|
Spree::Image.attachment_definitions[:attachment][key.to_sym] = value
end
end
Spree.user_class = "Spree::User"
end
我的 Gemfile 也是
source 'https://rubygems.org'
gem 'rails', '4.2.1'
ruby '2.2.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
end
gem 'spree', '3.0.1'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
gem 'rails_12factor', group: :production
gem 'pg'
gem 'aws-sdk'
【问题讨论】:
-
您是否使用回形针 gem 来处理图像?
-
是的,我正在使用回形针。
-
你有解决方案吗?我自己也在为此苦苦挣扎,无法让它发挥作用
-
在我正在进行的项目中,我发现 S3 无法正常工作,因为
Spree::Image已重新打开,并且path和url选项也设置在那里,这赢得了那些初始化程序中的设置。此外,从 Spree 3.0.2 开始,aws-sdk必须是< 2.0。希望这会有所帮助。
标签: ruby-on-rails heroku amazon-s3 paperclip spree