製品画像をアップロードするために Spree ショッピング カートを AWS S3 に接続しようとしていますが、エラーが発生し続けます。
.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activerecord-5.2.0/lib/active_record/dynamic_matchers.rb:22:in `m
ethod_missing': undefined method `has_one_attached'
これが私のセットアップです:
Gemfile
ruby '2.4.0'
gem 'rails', '~> 5.2.0'
gem 'spree', '~> 3.6.0'
gem 'spree_auth_devise', '~> 3.3'
gem 'spree_gateway', '~> 3.3'
gem 'globalize', github: 'globalize/globalize'
gem 'spree_i18n', github: 'spree-contrib/spree_i18n'
gem 'spree_globalize', github: 'spree-contrib/spree_globalize', branch: 'master'
gem 'spree_static_content', github: 'spree-contrib/spree_static_content'
gem 'aws-sdk', '~> 2.3'
config/initializers/spree.rb
attachment_config = {
s3_credentials: {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
bucket: ENV['S3_BUCKET_NAME']
},
storage: :s3,
s3_region: ENV['S3_REGION'],
s3_headers: { "Cache-Control" => "max-age=31557600" },
s3_protocol: "https",
bucket: ENV['S3_BUCKET_NAME'],
url: ":s3_domain_url",
styles: {
mini: "48x48>",
small: "100x100>",
product: "240x240>",
large: "600x600>"
},
path: "/:class/:id/:style/:basename.:extension",
default_url: "/:class/:id/:style/:basename.:extension",
default_style: "product"
}
attachment_config.each do |key, value|
Spree::Image.attachment_definitions[:attachment][key.to_sym] = value
end
誰かがこのエラーに遭遇し、解決策を持っていますか?