Rails 5.2 Active storage Unable to autoload constant ActiveStorage::Blob::Analyzable

2,286 views
Skip to first unread message

Mattia Antonini

unread,
Jun 10, 2018, 1:21:40 PM6/10/18
to Ruby on Rails: Talk
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 gem in gemfile. 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?

Thanks in advance.

Frantz Augustin

unread,
Jun 11, 2018, 12:46:15 PM6/11/18
to rubyonra...@googlegroups.com

Frantz Augustin
Founder @ Club Artizan



--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6c0c4919-81c4-4c08-b8b6-131ab76bf2f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Skt Hg

unread,
Jun 12, 2018, 8:18:58 AM6/12/18
to Ruby on Rails: Talk
Hi Frantz

I have an issue similar to Mattia's, so I tried your suggestion.
Thanks for the advice, although installing mini_magick (v4.8) didn't solve the issue for me.

For context, I'm on ruby 2.4.2 / rails 5.2 / active storage 5.2
I followed this tutorial for the active storage setup

I tried to upload via a form and to directly attach a local file to an existing object in the rails console.
Strangely enough I have a first `NoMethodError: undefined method `[]' for nil:NilClass` when trying the first time, 
and the `Unable to autoload constant ActiveStorage::Blob::Analyzable` error the second time.

The full session log if it helps:

==========================
2.4.2 :001 > store = Store.first  Store Load (0.3ms)  SELECT  "stores".* FROM "stores" ORDER BY "stores"."id" ASC LIMIT $1  [["LIMIT", 1]] => #<Store id: "b02fb2d3-0d0a-4edd-9620-a770be10479b", subdomain: "test2", name: "new store", created_at: "2018-06-12 09:25:28", updated_at: "2018-06-1209:25:28">
2.4.2 :002 >
2.4.2 :003 >
2.4.2 :004 >
2.4.2 :005 >
2.4.2 :006 >   store.header_image.attach(io: File.open('/Users/skthg/Downloads/stock-photo-macro-close-up-portrait-of-woman-having-facial-beauty-treatment-in-spa-therapist-massaging-chin-693071524.jpg'), filename:'chin.jpg', content_type: 'image/jpeg', identify: false)
  ActiveStorage::Attachment Load (0.4ms)  SELECT  "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = $1 AND "active_storage_attachments"."record_type" = $2 AND "active_storage_attachments"."name" = $3 LIMIT $4  [["record_id", 0], ["record_type", "Store"], ["name", "header_image"], ["LIMIT", 1]]
NoMethodError: undefined method `[]' for nil:NilClass
        from (erb):12:in `<main>'
        from (irb):6
2.4.2 :007 > store.header_image.attach(io: File.open('/Users/skthg/Downloads/stock-photo-macro-close-up-portrait-of-woman-having-facial-beauty-treatment-in-spa-therapist-massaging-chin-693071524.jpg'), filename:'chin.jpg', content_type: 'image/jpeg', identify: false)
LoadError: Unable to autoload constant ActiveStorage::Blob::Analyzable, expected /Users/skthg/.rvm/gems/ruby-2.4.2/gems/activestorage-5.2.0/app/models/active_storage/blob/analyzable.rb to define it
        from (irb):7
2.4.2 :008 >




Regards

2018年6月11日月曜日 18時46分15秒 UTC+2 Frantz Augustin:

Frantz Augustin
Founder @ Club Artizan


On Sun, Jun 10, 2018 at 11:23 AM, Mattia Antonini <mattia.an...@gmail.com> wrote:
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 gem in gemfile. 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?

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

Skt Hg

unread,
Jun 12, 2018, 2:04:36 PM6/12/18
to Ruby on Rails: Talk
Replying to myself in case someone hits the same issue.

First thanks Frank for the pointers you sent me. I am new to rails so it was very helpful to debug from a clean state.

I got to solve it, the main issue for me was a parsing error in the ‘storage.yml’ file. The storage engine was chocking on it, even if the file was passing several linters fine.
I kept the original file for later review, but rewriting it from scratch solved the issue.

Best

Frantz Augustin

unread,
Jun 12, 2018, 9:00:16 PM6/12/18
to rubyonra...@googlegroups.com
I am glad you solved it.

Frantz Augustin
Founder @ Club Artizan


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3d425c73-21c8-47b1-b353-f6f09716cb6d%40googlegroups.com.

Mattia Antonini

unread,
Jun 14, 2018, 12:16:54 PM6/14/18
to Ruby on Rails: Talk
Hi Skt Hg,

Could you tell me, step by step, how you solved this problem?
I'm new to rails too.

Thanks, Mattia.

Kody

unread,
Mar 28, 2019, 3:23:53 PM3/28/19
to Ruby on Rails: Talk
Thank you! I was having a similar problem and it was the storage.yml file having issues. This post helped point me in that direction and track down the problem. (My :amazon section of the storage.yml wasn't set up correctly, and the storage.yml wasn't valid .yml). 

Best wishes,

Kody
Reply all
Reply to author
Forward
0 new messages