ActionText - AWS - Ruby on Rails images not uploading

I recently deployed an app on here, a “development” app with Ruby on Rails. It’s a small app and won’t get much traction so I started with that and figured I could scale up as necessary.

But I’m running into a weird issue with ActionText. Even though I thought the deployed version was production (is it?), it seems to be trying to store ActionText files locally. I’m following these guides:

There error I’m getting is a routing error:
ActionController::RoutingError (No route matches [GET] “/assets/actiontext.css”):

But it shouldn’t be trying to access this if I’m understanding correctly.

EDIT: I figured it out
The issue was multi-layered, but it does involve Fly.io, so it’s still relevant here:

  1. Follow the ActionText and ActionStorage guides
  2. Follow Amazon’s gem instructions! These are the latest straight from amazon
    Using the SDK with Ruby on Rails - AWS SDK for Ruby
  3. Make sure set up an initializer for aws (this one wasn’t mentioned anywhere in the rails docs to my knowledge) in your config/initializer folder. You can just create a file called aws.rb
    Here’s my /config/initializer/aws.rb file that I created:
require 'aws-sdk-s3'

Aws.config.update({
  region: ENV['region'],
  credentials: Aws::Credentials.new(ENV['access_key_id'], ENV['secret_access_key']),
})

S3_BUCKET = Aws::S3::Resource.new.bucket(ENV['bucket'])
  1. You need to set up your Cross-origin resource sharing (CORS) configuration in your bucket (you should’ve set up your AWS bucket by this point, but if not, there are plenty of tutorials that get you that far) It should look like this, replace the <> with your own information and the parenthesis () are my comments
[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT"
        ],
        "AllowedOrigins": [
            "https://<app domain>",
            "https://localhost:3000"
        ],
        "ExposeHeaders": []
    }
]

EDIT again looks like the thread I linked to in the previous edit was wrong. This was just a mistake on my end haha.

Another thing to note for Ruby on Rails and ActionText is that ActionText tries to upload the file directly from the browser. If you see a grey line, it either hasn’t finished uploading yet or it never will finish. This means you need to adjust your CORS configuration (most likely).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.