Tom Dringer


2,080 Experience
8 Lessons Completed
1 Question Solved


Posted in What's the best way to debug Amazon S3 errors

Hi everyone,

So far in my rails journey, the most frustrating thing by far has been using Amazon S3 for storage. I have had various issues, all without error messages, which is like looking for a needle in a haystack.
How do you debug issues with Amazon S3? For instance at the moment, development shows some images and not all, on my staging server no images are displayed, and production currently shows all images. When I use the browser tools no address for the image is even loaded:

<div class="card-img" variant="top" itemprop="image" title="The racing machine driven by joe blogs" style="background: url(< nothing >) no-repeat; background-size: cover">

I am looking to deploy some big changes to production, but don't feel confident with missing images.

On a side note, I recently upgraded my rails version and my active storage versions, running the migrations and adding the service column to the blobs table. I'm hoping maybe I made some sort of error in the migration.

Please let me know your experiences with Amazon S3. Thanks!

Posted in Rails 6.1 Active Text Javascript errors

I am making an article section in my Rails app. For this reason I thought Active Text would be a good idea. I have added it as per the Rails Guides as per but when i try to upload an image i get the following errors:

Failed to load resource: the server responded with a status of 422 (Unprocessable Entity)

and also

Uncaught Error: Direct upload failed: Error creating Blob for "foxes.jpg". Status: 422
at AttachmentUpload.directUploadDidComplete (attachment_upload.js:37)
at BlobRecord.callback (activestorage.js:875)
at BlobRecord.requestDidError (activestorage.js:760)
at BlobRecord.requestDidLoad (activestorage.js:754)
at XMLHttpRequest.<anonymous> (activestorage.js:728)

This seems to happen on every environment apart from development. I am also using AWS S3 and Cloudfront and i think the settings are all good for that.

Anyone else tried ActiveText, S3 and Cloudfront?


Hi, I am having to use a different computer whilst mine is in for repair. So i generated the SSH keys to be used for deployment with Hatchbox. Using [email protected] or [email protected] just gives me an error Permission denied (publickey). Does anyone know a fix for this? I am locked out of my server and i desperately need to check the logs for an error which is giving me a white screen of death. Thanks

Posted in Space Upgrades - A browser game made in Rails

Wow thats awesome!

Posted in Order by score using Pagy pagination?

@joshBrody - just check default scope is only going to be in the model or the controller i guess?

Posted in Order by score using Pagy pagination?

I've just checked and i don't have default scope anywhere

Posted in Order by score using Pagy pagination?

Hi everyone. I am currently trying to order some ActiveRecord records by score. In my controller i have:

def index
    @pagy, @drivers = pagy(
            '(drivers.no_races + drivers.no_poles + drivers.no_podiums + drivers.no_wins) AS score'
        ).reorder('drivers.score DESC'),
        page: params[:page],
        items: 16

I am using Pagy for the pagination. As the code shows, I do a query to select all drivers and then add together 3 columns in the table as 'score'. I then want to order by score going from high to low and show 16 records per page.
When the page loads it seems to order by driver id. I can't see anywhere else that i have an order by, but i did add reorder to override anything else.
Anyway for whatever reason i'm stuck with the wrong ordering. Any direction is appreciated :-)

Mockup -

Posted in Hatchbox deployment. public/index.html not found

Ok i made a staging enviroment in my app, which i guess could be the issue. I have environment variables on Hatchbox using staging, rather than p[roduction. I'll dig deeper. Thanks

Posted in Hatchbox deployment. public/index.html not found

Cool can i set this somewhere? My path should be pretty default. Its just app/

Posted in Hatchbox deployment. public/index.html not found


I am deploying to hatchbox and everything appears fine until i load the site up in the browser. Looking at the logs there is no public/index.html. On my development environment there is also no index file in public. I am using Rails 6 which apparently doesn't build a public index.html file?

Posted in Postgres issues

I now have Postgres running on my local machine nicely. My issue now is i can't run a migration due to the following error:

ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "drivers" does not exist
LINE 8: WHERE a.attrelid = '"drivers"'::regclass

There should be a relationship between a user and a driver, where the user has one driver.

In my user (Devise) model I have has_one :driver

and in my driver migration I have:

t.string :user_id
t.belongs_to :user

So in the driver table the user_id field should hold the

Any direction is appreciated.

Posted in Postgres issues


So as i began a project earlier in the year, i decided to go full Docker for deployment. That was all good except debugging and stuff proved difficult so this weekend i decided to make the project native and use something for deployment.
Long story short, now i have gone back to a native based project (i.e no Docker), my Postgres installation (which was fine in the beginning) now just does not work.
I had issues with port numbers (which i have since managed to fix) and no issues with database not found. To make things worse, i think (i'm on macos and using Rubymine) i have Postgres installed via the OS, multiple versions by Homebrew, and some from standalone Postgres apps.
So obviously with these issues, i can;t start my app or run migrations etc.

Has anyone had this issue when moving away from Docker?

My error at the moment is no database named "xxx". I thought when i did i migration its all taken from the database.yml? I've run commands like rake db:create and similar.

I'm not totally sure the db i am connected to is even the right one.

Posted in Pretty urls with FriendlyID Discussion

Is it possible to to make the url "{id}-{user.fname}-{user.lname}"? It seems to work fine clicking on links, but as soon as i try to create, edit, or delete anything i get route not found.


I want to validate my image upload field by making a user upload only a square image (i.e 200px x 200px). I'm basically wanting square image dimentions so it will resize and nicely and not look disproportional. Can this be done? Thanks

Posted in Share resources among controllers?

Anyone interested in this, in the news controller under def index you can just add the variable @students = Students.all or whatever and it really is as simple as that.

Posted in Share resources among controllers?

I'm thinking i need to look at Nested Resources?

Posted in Share resources among controllers?


I’m not even sure I’m using the correct terminology here (sharing resources among controllers) but here goes.
Imagine I have a page called students with the usual CRUD functionality and another page with another controller called news or something. If the student page had a table called students with first name, second name etc ... how would I use the student table in the news template so I could do a for each student to list names or whatever? This is where things start to fall apart in my understanding of Rails. Thanks!

Posted in Liking Posts Discussion

I am also having the 404 issue but it's something to do with routes i'm guessing?

ActionController::RoutingError (uninitialized constant Developments):

and then in the console:

POST http://localhost:3000/developments/1/like [HTTP/1.1 404 Not Found 1343ms]

When i run rake routes I get the following:

new_development_like GET /developments/:development_id/like/new(.:format) developments/likes#new

edit_development_like GET /developments/:development_id/like/edit(.:format) developments/likes#edit

development_like GET /developments/:development_id/like(.:format) developments/likes#show

PATCH /developments/:development_id/like(.:format) developments/likes#update
PUT /developments/:development_id/like(.:format) developments/likes#update
DELETE /developments/:development_id/like(.:format) developments/likes#destroy
POST /developments/:development_id/like(.:format) developments/likes#create

Any feedback is appreciated. Thanks!

Posted in Adding Javascript to Rails 6

Wow that really is above and beyond! Thank you so much!

Posted in Adding Javascript to Rails 6

Thanks for the feedback. I get the same error still, but this time much more detailed.

Uncaught ReferenceError: toastr is not defined
<anonymous> (index):38
dispatch turbolinks.js:75
notifyApplicationAfterPageLoad turbolinks.js:994
pageLoaded turbolinks.js:948
e turbolinks.js:872
start turbolinks.js:882
start turbolinks.js:1040
<anonymous> application.js:24
<anonymous> application-51d3c38d384dcac9fb08.js:2
Webpack 3
<anonymous> (index):38
dispatch turbolinks.js:75
notifyApplicationAfterPageLoad turbolinks.js:994
pageLoaded turbolinks.js:948
e turbolinks.js:872
(Async: EventListener.handleEvent)
start turbolinks.js:882
start turbolinks.js:1040
<anonymous> application.js:24
<anonymous> application-51d3c38d384dcac9fb08.js:2

I have cleared my cache and all the usual things. Is there anything i should be looking out for in those errors?

I load my js in the head tag on my application layout file<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>


logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.