1

I have a web app working on heroku right now, I configure my app to stored in assets the fav-icon and company logo that I and use only in the login.

The problem is that Im trying to use activestorage and aws s3 to start uploading images of my employees in heroku.

I follow all documentation to use activestorage and all docs about how to configure Heroku and AWS S3.

runing my app local works with activestorage and s3 I can upload images to my S3 bucket and all looks great, the problem is when I try to deploy this version to heroku the upload (when i use "git push heroku master") don't mark any error but when i try to access my app my app these do not work.

My heroku logs show me

2020-03-27T16:38:47.835694+00:00 app[web.1]: from bin/rails:9:in `<main>'
2020-03-27T16:38:47.889395+00:00 app[web.1]: => Booting Puma
2020-03-27T16:38:47.889418+00:00 app[web.1]: => Rails 5.2.4.1 application starting in production
2020-03-27T16:38:47.889419+00:00 app[web.1]: => Run `rails server -h` for more startup options
2020-03-27T16:38:47.889419+00:00 app[web.1]: Exiting
2020-03-27T16:38:57.236728+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/admin/client" host=admin.ttpn.com.mx request_id=6568febe-d894-4751-bf2c-c6d8d1539146 fwd="189.237.90.141" dyno= connect= service= status=503 bytes= protocol=https

My employee model have the fields to use with railsandmin and the code to use activestorage :

class Employee < ApplicationRecord

  has_one_attached :avatar
  attr_accessor :remove_avatar
  after_save { avatar.purge if remove_avatar == '1' }

The rails_admin configuration to use images is:

rails_admin do
    create do
      field :avatar, :active_storage
      field ...
    end

    edit do
      field :avatar, :active_storage do
        delete_method :remove_avatar
      end
      field ...
      end
    end
end

My storege.yml code is:

local:
  service: S3
  access_key_id: <%= Rails.application.credentials.amazon[:access_key_id] %>
  secret_access_key: <%= Rails.application.credentials.amazon[:secret_access_key] %>
  region: <%= Rails.application.credentials.test[:region] %>
  bucket: <%= Rails.application.credentials.test[:bucket] %>

amazon:
  service: S3
  access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
  secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
  region: us-east-2
  bucket: <%= ENV['BUCKET_NAME'] %>

All ENV[] variable are configured right now in Heroku.

Some one can help me to found a solution why my app dont work in heroku

Tks

  • It may not have anything to do with AWS. I see the Heroku [H10](https://devcenter.heroku.com/articles/error-codes#h10-app-crashed) error code mentioned in the last line of your error message. I would google that (there are some heavily upvoted reasons for it on other questions/answers). Example [here](https://stackoverflow.com/q/14322989/5783745) – stevec Dec 20 '20 at 14:28

1 Answers1

0

@antonio-castellanos-loya considering you stated that the application works fine in your local environment, is uploading images to s3 in development, AND is deploying without failing, I'm going to make the assumption that this is an issue with your heroku instance.

did you try running the migrations on the heroku instance? heroku run rails db:migrate

This is the first thing I'd check, especially since your app is exiting immediately upon booting as per your logs.

frostini
  • 175
  • 10