I've just upgraded a 5.1.4. app to 5.2 and am trying to swap out Paperclip for ActiveStorage. At the moment when trying to update an existing record with an image, I get the following error:
Unable to autoload constant ActiveStorage::Blob::Analyzable, expected /Users/Simon/.rvm/gems/ruby-2.4.0/gems/activestorage-5.2.0/app/models/active_storage/blob/analyzable.rb to define it
In my model:
has_one_attached :pic
In my controller:
...
  def update
    respond_to do |format|
      if @gin.update(gin_params)
        format.html { redirect_to @gin, notice: 'Gin was successfully updated.' }
        format.json { render :show, status: :ok, location: @gin }
      else
        format.html { render :edit }
        format.json { render json: @gin.errors, status: :unprocessable_entity }
      end
    end
  end
...
 def gin_params   params.require(:gin).permit(:name, :text, :snippet,
 :pic, :slug, :abv, distillery_attributes: [:id, :name], botanical_ids:
 []) end
In storage.yml:
   amazon:
    service: S3
    access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
    secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
    region: xx-xxxx-x
    bucket: xxxxxxx
I set the access keys via rails credentials:edit
In development.rb:
 config.active_storage.service = :amazon
In my views:
<%= image_tag @gin.pic, class: "border shadow-lg" %>
I've been reading though http://edgeapi.rubyonrails.org/classes/ActiveStorage/Blob/Analyzable.html but it doesn't make too much sense to me.
The error has made me look for the file at app/models/active_storage/blob/analyzable.rb but I can't see it in my app?
What have I missed?
I've got exactly same error. For me it was because credentials for AWS S3 were missing (it was missing from credentials.yml.enc)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With