Ruby on Rails Tuesday, June 12, 2018

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.
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.

--
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/bbce1fa7-65ec-48b7-8ae2-1f690d9f6a3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment