Невозможно автоматически загрузить константу ActiveStorage :: Blob :: Analyzable - PullRequest
0 голосов
/ 10 января 2019

Я посмотрел на каждое возможное решение этой ошибки, но ничего не решило.

Каждый раз, когда я пытаюсь загрузить изображение, я получаю эту ошибку:

Unable to autoload constant ActiveStorage::Blob::Analyzable, expected /usr/local/lib/ruby/gems/2.5.0/gems/activestorage-5.2.2/app/models/active_storage/blob/analyzable.rb to define it.

Gemfile

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.5.1'

gem 'rails', '~> 5.2.0'
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby

gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'

# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Reduces boot times through caching; required in config/boot.rb
# Causing crashes. Removing for now
# gem 'bootsnap', '>= 1.1.0', require: false

# Well maintained fork with several patches and compatability for Rails 5.x
# If we need to we can fork this and take ownership of it. Much better than building from scratch.
# gem 'casino', git: "https://github.com/identification-io/CASino.git", branch: "master"
gem 'casino', git: "https://github.com/webappsllc/CASino.git", branch: "master"
# gem 'casino', path: '/Users/justin/dev/oss/CASino'
gem 'grape', '~> 1.1.0' # Pinned

gem 'wisper', '~> 2.0'
gem 'rack-cors', require: 'rack/cors'

# Form Objects
gem "reform", ">= 2.2.0"
gem "reform-rails"
gem "dry-validation"

# Free optimization
gem 'fast_blank'

# Hashids to obscure legacy_ids
gem 'hashids'

# Send Emails via Amazon SES
gem 'aws-sdk-rails'

# Upload Files via Amason S3
gem "aws-sdk-s3", require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'guard-rspec', require: false
  gem 'dotenv-rails', require: 'dotenv/rails-now'
  gem 'spring-commands-rspec'
  gem 'parallel_tests', group: [:development, :test]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'grape_on_rails_routes'
  gem "better_errors"
  gem "binding_of_caller"
  gem "letter_opener"
  gem 'letter_opener_web', '~> 1.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15', '< 4.0'
  gem 'selenium-webdriver'
  # Easy installation and use of chromedriver to run system tests with Chrome
  gem 'chromedriver-helper'
  gem 'factory_bot'
  gem 'rspec'
  gem 'rspec-rails'
  gem 'database_cleaner'
  gem 'faker'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
# gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

В config/application.rb У меня есть require 'active_storage/engine' без комментариев.

В config/environments/development.rb У меня настроено config.active_storage.service = :local.

Я бегал rails active_storage:install и rails db:migrate.

Название модели: user_test

class UserTest < ApplicationRecord
  has_one_attached :image
end

У меня есть это в app / controllers / user_tests_controller.rb

def user_test_params
  params.require(:user_test).permit(:title, :caption, :image)
end 

** конфиг / storage.yml *

test:
  service: Disk
  root: <%= Rails.root.join("tmp/storage") %>

local:
  service: Disk
  root: <%= Rails.root.join("storage") %>

Я действительно не понимаю, почему это не работает.

1 Ответ

0 голосов
/ 16 января 2019

У вас есть config.active_storage.service = :amazon, установленный в вашем development.rb случайно?

Я получил вышеупомянутую ошибку, и это закончилось тем, что у меня была вышеупомянутая строка, но env vars AWS не были установлены.

...