title: Unable to autoload constant ActiveStorage::Blob::Analyzable Error with Rails 5.2, AWS S3, and ActiveStorage
body: <p>I've been battling this guy for a while and have done all the Googlies on it (<a href="https://stackoverflow.com/questions/50792581/rails-active-storage-unable-to-autoload-constant-activestorageblobanalyzable">here</a>, <a href="https://stackoverflow.com/questions/50307502/blob-error-with-active-storage-rails-5-2">here</a>, and many equally-unhelpful others) but to no avail.</p>
  
  <p>The official error is this, called on the first line of my create method:</p>
  
  <blockquote>
    <p>Unable to autoload constant ActiveStorage::Blob::Analyzable, expected
    /Users/lizbayardelle/.rvm/gems/ruby-2.5.0/gems/activestorage-5.2.1/app/models/active_storage/blob/analyzable.rb
    to define it</p>
  </blockquote>
  
  <p>I'm creating a <code>blog</code> model, which <code>has_one_attached</code> <code>:pdf</code> and one <code>:image</code>, both through ActiveStorage.  These relationships are all in the <code>blog</code> model:</p>
  
  <pre><code>class Blog &lt; ApplicationRecord
    belongs_to :user
    has_one_attached :image
    has_one_attached :pdf
  end
  </code></pre>
  
  <p>My controller <code>blogs#create</code> model is here:</p>
  
  <pre><code>  def create
      @blog = Blog.new(blog_params)
      @blog.user_id = current_user.id
      if @blog.published
        @blog.published_on = DateTime.current
      end
  
      respond_to do |format|
        if @blog.save
          @blog.image.attach(params[:image])
          @blog.pdf.attach(params[:pdf])
          format.html { redirect_to @blog, notice: 'Blog was successfully created.' }
          format.json { render :show, status: :created, location: @blog }
        else
          format.html { render :new }
          format.json { render json: @blog.errors, status: :unprocessable_entity }
        end
      end
    end
  </code></pre>
  
  <p>With this as my params:</p>
  
  <pre><code>def blog_params
    params.require(:blog).permit(:title, :teaser, :body, :cta, :category, :linked_module, :published, :published_on, :user_id, :image, :pdf)
  end
  </code></pre>
  
  <p>I followed <a href="https://stackoverflow.com/questions/50792581/rails-active-storage-unable-to-autoload-constant-activestorageblobanalyzable">this</a> tutorial to set up ActiveStorage with S3 and <a href="https://stackoverflow.com/questions/50307502/blob-error-with-active-storage-rails-5-2">this</a> one to set up ActiveStorage in general.</p>
  
  <p>My <code>storage.yml</code> looks like this:</p>
  
  <pre><code>    test:   service: Disk   root: &lt;%= Rails.root.join("tmp/storage") %&gt;
  
      local:   service: Disk   root: &lt;%= Rails.root.join("storage") %&gt;
  
      # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) amazon:   service: S3   access_key_id: &lt;%= ENV["AWS_ACCESS_KEY_ID"] %&gt;   secret_access_key: &lt;%= ENV["AWS_SECRET_ACCESS_KEY"] %&gt;   region: us-west-1   bucket: *bucket name*
  
  With this in my `secrets.yml` (which is GitIgnored, if it makes a difference):
  development:
    secret_key_base: actual key here
    AWS_ACCESS_KEY_ID: actual key here
    AWS_SECRET_ACCESS_KEY: actual key here
  test:
    secret_key_base: actual key here
  
  # Do not keep production secrets in the repository,
  # instead read values from the environment.
  production:
    AWS_ACCESS_KEY_ID: &lt;%= ENV["AWS_ACCESS_KEY_ID"] %&gt;
    AWS_SECRET_ACCESS_KEY: &lt;%= ENV["AWS_SECRET_ACCESS_KEY"] %&gt;
    secret_key_base: &lt;%= ENV["SECRET_KEY_BASE"] %&gt;
    recaptcha_site_key: &lt;%= ENV["RECAPTCHA_SITE_KEY"] %&gt;
    recaptcha_secret_key: &lt;%= ENV["RECAPTCHA_SECRET_KEY"] %&gt;
  </code></pre>
  
  <p>My new blog form looks like this:</p>
  
  <pre><code>&lt;%= simple_form_for(@blog) do |f| %&gt;
    &lt;%= f.error_notification %&gt;
    &lt;%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %&gt;
  
    &lt;div class="form-inputs"&gt;
      &lt;div class="form-group"&gt;
        &lt;%= f.label :category %&gt;
        &lt;%= f.select :category, options_for_select(['General', 'House', 'Spouse', 'Kids', 'Other'], { class: "form-control" }) %&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;%= f.label :title %&gt;
        &lt;%= f.text_field :title, class: "form-control" %&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;%= f.label :teaser %&gt;
        &lt;%= f.text_area :teaser, class: "form-control" %&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;%= f.label :body %&gt;
        &lt;%= f.trix_editor :body %&gt;
      &lt;/div&gt;
        &lt;div class="form-group"&gt;
        &lt;%= f.label :cta %&gt;
        &lt;%= f.text_field :cta, class: "form-control" %&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;%= f.label :linked_module %&gt;
        &lt;%= f.text_field :linked_module, class: "form-control" %&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;%= f.label "Blog Image" %&gt;&lt;br /&gt;
        &lt;%= f.file_field :image %&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;%= f.label "Linked PDF" %&gt;&lt;br /&gt;
        &lt;%= f.file_field :pdf %&gt;
      &lt;/div&gt;
      &lt;div class="form-group text-center"&gt;
        &lt;%= f.input :published %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
    &lt;div class="form-actions text-center"&gt;
      &lt;%= f.button :submit %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I did input the config keys to Heroku, but since this error is on localhost I can't see that making a difference.  I also made sure minimagick is installed.</p>
  
  <p>Can anyone see what's going wrong here?  I'm really growing to hate ActiveStorage after all the issues it's giving me...</p>
  
  <p><strong>ADDITIONAL INFORMATION</strong></p>
  
  <pre><code>Here's my Gemfile:
  
  source 'https://rubygems.org'
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
  
  ruby '2.5.0'
  
  gem 'rails', '~&gt; 5.2.0'
  gem 'puma', '~&gt; 3.11'
  gem 'sass-rails', '~&gt; 5.0'
  gem 'uglifier', '&gt;= 1.3.0'
  gem 'coffee-rails', '~&gt; 4.2'
  gem 'jbuilder', '~&gt; 2.5'
  gem 'mini_magick'
  gem 'jquery-rails'
  gem 'devise'
  gem 'bootsnap'
  gem 'bootstrap', '~&gt; 4.1.3'
  gem 'sprockets-rails'
  gem 'bootstrap-sass'
  gem 'bcrypt', '~&gt; 3.1.7'
  gem 'friendly_id', '~&gt; 5.1.0'
  gem 'stripe'
  gem 'figaro'
  gem 'magnific-popup-rails', '~&gt; 1.1.0'
  gem 'simple_form'
  gem 'acts-as-taggable-on'
  gem 'aws-sdk' , '~&gt; 3'
  gem 'aws-sdk-s3', require: false
  gem 'simple_form_extension'
  gem 'recaptcha', require: "recaptcha/rails"
  gem 'font-awesome-rails'
  gem 'trix', git: 'https://github.com/bcoia/trix.git'
  
  group :production do
    gem 'pg', '~&gt; 0.20.0'
    gem 'rails_12factor'
  end
  
  group :development, :test do
    gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
    gem 'sqlite3'
  end
  
  group :development do
    gem 'sqlite3'
    gem 'web-console', '&gt;= 3.3.0'
    gem 'listen', '&gt;= 3.0.5', '&lt; 3.2'
    gem 'spring'
    gem 'spring-watcher-listen', '~&gt; 2.0.0'
  end
  
  group :test do
    gem 'sqlite3'
    gem 'capybara', '&gt;= 2.15', '&lt; 4.0'
    gem 'selenium-webdriver'
    gem 'chromedriver-helper'
  end
  
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
  
  
    [1]: https://medium.com/alturasoluciones/setting-up-rails-5-active-storage-with-amazon-s3-3d158cf021ff
    [2]: https://edgeguides.rubyonrails.org/active_storage_overview.html
  </code></pre>