I just have one question after doing plenty of res...
# support
d
I just have one question after doing plenty of research. I'm getting the following error when deploying to Heroku using "git push heroku main": Detecting rake tasks remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: rake aborted! remote: NoMethodError: undefined method `has_one_attached' for Spree:ImageClass remote: Did you mean? has_attached_file Clearly there is a method in Spree:Image:Class that isn't working - I just don't know where to find that file. Anyone have any ideas about this issue in general?
j
I'm not sure about that exact issue, but (if I remember correctly)
has_attached_file
is a Paperclip thing and
has_one_attached
I assume is ActiveStorage. We've switched to ActiveStorage as the default backend... but it look like something is wonky with your setup.
a
Have you specified in the spree initializer the
image_attachment_module
?
Copy code
config.image_attachment_module = 'Spree::Image::PaperclipAttachment'
config.taxon_attachment_module = 'Spree::Taxon::PaperclipAttachment'
I remember I had to do this once upgraded. Docs: https://github.com/solidusio/solidus/discussions/4030#discussioncomment-633922
d
@afdev82 - tried your suggestion, it didn't work, but it gave me some ideas for continuing to troubleshoot the Spree attachment config.
In config > initializers > spree.rb: Commenting out the Spree::Image.attachment_definitions line below enabled the Heroku build to complete successfully. if Rails.env.production? 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_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: 'noimage/:style.png', default_style: 'product' } attachment_config.each do |key, value| #Spree:Image.attachment definitions[attachment][key.to_sym] = value end end
a
Yes, in the linked comment they say:
Take care you don't have any customization of Spree::Image.attachment_definitions before that preference (even in other initializer files loaded before, eg config/initializers/paperclip.rb). If you do, you'll see the error described above.
Please follow what they say about moving them in a decorator