I'm trying to replace the depreciated (for Rails 5.2) paperclip with image uploads using ActiveStorage and aws s3. I'm using this guide and the GoRails episode on it, but have hit a console error I can't parse. Everything looks okay on my form, but when I go to submit I get this in my console:
activestorage.self-6e8d967adecc8b2a7259df0f51ef5b6f171c33267c7d149a474beccd90c68697.js?body=1:1 POST http://localhost:3000/rails/active_storage/direct_uploads 500 (Internal Server Error)
I have this on my blogs#new
_form.html.erb
:
<div class="form-group">
<%= f.label "Picture" %>
<%= f.file_field :image, direct_upload: true %>
</div>
I put this in my model:
has_one_attached :image
I have :image
in my params
def blog_params
params.require(:blog).permit(:title, :teaser, :body, :user_id, :tag_list, :link_text, :link_filename, :pillars_id, :image)
end
I added this to my storage.yml
:
Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
amazon:
service: S3
access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %>
secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %>
region: us-west-1
bucket: nameofbucket
And this in my development environment:
config.active_storage.service = :amazon
I included the javascript/css from the RubyOnRails Guides linked above. Anyone see where this error is coming from? I'm not too experienced with debugging console errors, so any info or wisdom is appreciated.
ADDITIONAL INFORMATION
Here's the error that happens in my Rails Console:
LoadError - Unable to autoload constant ActiveStorage::Blob::Analyzable, expected /Users/lizbayardelle/.rvm/gems/ruby-2.3.3/gems/activestorage-5.2.0/app/models/active_storage/blob/analyzable.rb to define it:
::1 - - [12/Jul/2018:13:56:05 PDT] "POST /rails/active_storage/direct_uploads HTTP/1.1" 500 7784
http://localhost:3000/blogs/new -> /rails/active_storage/direct_uploads
Other Note
When I try to create a blog without an image I get this error:
undefined method `[]=' for nil:NilClass