Ryan
Ryan

Reputation: 41

Rails - Activestorage causing rails configuration failure

I am having an issue trying to deploy my app to heroku with rails active storage. In development I have no issues using config.active_storage.service = :local and all works as it should. However in my production.rb file I have set config.active_storage.service = :amazon and followed the set up guides.

My storage.ymlis as follows:

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

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

 amazon:
    service: S3
    access_key_id: <%= ENV['S3_ACCESS_KEY'] %>
    secret_access_key: <%= ENV['S3_SECRET_ACCESS_KEY'] %>
    region: <%= ENV['S3_REGION'] %>
    bucket: <%= ENV['S3_BUCKET_NAME'] %>

When I run git push heroku master, the app will deploy, but the following error will appear in the logs: "Detecting rails configuration failed".

I am unable to open the app and the herkou log will display the following error: "Missing configuration for the :amazon Active Storage service. Configurations available for [:test]".

This same error occurs if I change config.active_storage.service = :amazon to config.active_storage.service = :local however if I change it to config.active_storage.service = :test

the app will deploy without error and I am able to open the app and upload files as expected.

I have trawled the web but haven't seen anyone else with this error, so any comments or thoughts are appreciated. Thanks in advance.

Upvotes: 4

Views: 3041

Answers (1)

freshop
freshop

Reputation: 245

The problem is the indentation in storage.yml test: local: are indented one space, and amazon: is indented two spaces.

I had the same problem, and it was hard to notice an extra space. In YAML the spaces matter, but Ruby devs are not accustomed to having the spaces matter.

Upvotes: 2

Related Questions