1

I've updated rails from 5.1.4 to 5.2 and remove Papaerclip to use Active Storage. I'm using digitalocean spaces. In my development env I've setted credentials in storage.yml to save images to digitalocean.

I've added aws-sdk-s3 gem in gemfile (without version, may be this the problem?).

I run db:migrate for active storage.

But when I'm going to submit the form with an image upload html tag, i receive this error:

Unable to autoload constant ActiveStorage::Blob::Analyzable.

Anyone can help me?

Sanoop Surendran
  • 3,484
  • 4
  • 28
  • 49
Bistaff
  • 133
  • 2
  • 12

3 Answers3

2

Did you install MiniMagic Gem

http://api.rubyonrails.org/classes/ActiveStorage/Analyzer/ImageAnalyzer.html

  • 3
    This was my issue. I upgraded to Rails 6.0, and wanted to use Vips for image processing, however Active Storage still requires MiniMagik for Image Analysis. Jesus I hate Active Storage. – Paul Danelli Oct 10 '19 at 14:45
2

If you are updating from an older version of Rails to a version that contains ActiveStorage, it is important to create the boiler plate storage.yml. You may have stored your credentials through

rails credentials:edit

And your setup for S3 might look similar to this:

amazon:
  service: S3
  access_key_id: <%= Rails.application.credentials.aws[:access_key_id] %>
  secret_access_key: <%= Rails.application.credentials.aws[:secret_access_key] %>
  region: <%= Rails.application.credentials.aws[:region] %>
  bucket: <%= Rails.application.credentials.aws[:bucket] %>

The issue that I had was that when I saved my credentials on storage.yml, all of the keys were saved as comments. Run EDITOR='atom --wait' rails credentials:edit (with the editor that you are using; in this example, I am using atom) and make sure that none of your items are commented through #'s. When you close the window, your credentials should automatically be saved and can be accessed.

Hope that helps!

1

Believe it or not, I ran into the same error. Only to find out hour later, that the issue was in my storage.yaml file

There was an error in the logs Psych::SyntaxError - (<unknown>): did not find expected key while parsing a block mapping at line 1 column 1:

which meant that Psych which is a YAML parser was having an issue with parsing the file.

It was throwing the Unable to autoload constant ActiveStorage::Blob::Analyzable Error because of a Spacing issue

Hope this helps anyone out there

EXAMPLE BEFORE

| amazon:
    service: S3
    access_key_id: <%= Rails.application.credentials.aws[:access_key_id] %>
    secret_access_key: <%= Rails.application.credentials.aws[:secret_access_key] %>
    region: <%= Rails.application.credentials.aws[:region] %>
    bucket: <%= Rails.application.credentials.aws[:bucket] %>

EXAMPLE AFTER

|amazon:
   service: S3
   access_key_id: <%= Rails.application.credentials.aws[:access_key_id] %>
   secret_access_key: <%= Rails.application.credentials.aws[:secret_access_key] %>
   region: <%= Rails.application.credentials.aws[:region] %>
   bucket: <%= Rails.application.credentials.aws[:bucket] %>
Mr. Rene
  • 1,167
  • 10
  • 17