Category Archives: Uncategorized

High Tea React App Deployed on AWS

I am inordinately proud of a React App I just built.

It is an update of one of the first Rails Apps I ever made, and that I still use to this day – my app to rate high teas.

This new version (note: there is a bug that means you have to wait or reload, must fix) is a React app that pulls data from my old version via an API. I then deployed it onto AWS S3. The code can be found here, but some details that I want to point out are:

  • I was originally very bamboozled by how to set up a JS project, thus I recorded some notes here.
  • I used webpack to bundle it up, and then deployed the dist folder to an s3 bucket on AWS with: aws s3 sync dist/ s3://high-tea --acl public-read --delete --profile profileName 
Leave a reply

Backing up your database from Heroku

I’m writing a quick post on this, because every time I do it I fck around for a while and eventually get it – so this time I am writing my steps!

And yes, I know there is documentation on Heroku, but it never quite works for me. So!

  1. Make sure you have a database created and migrated into which you are going to put your backup
  2. Capture a backup with $heroku pg:backups capture --app rails-girls-events
  3. It will give you a backup id, which you can use in the next command to get the public url of that backup $heroku pg:backups public-url b006 --app rails-girls-events
  4. When you visit that url, it will download to your machine
  5. Use the path to that download to upload it $pg_restore --verbose --clean --no-acl --no-owner -h localhost -U tracymusung -d your-data-base-name path-to-your-download


Leave a reply

Handling Ruby Exceptions and Errors

How to handle exceptions in Ruby? What do `raise` and `rescue` do?

def walk_the_dog(dog)
if dog == nil or dog.size == 0
raise"Can't walk nothing")
puts "Walking #{dog}"

You can use a raise here, to make sure that there is always a dog when you puts "Walking #{dog}". Note that fail is the same raise.

If this raise gets called, nothing after that line will be run.

Exception Handling

If you don’t want your code to just stop when it hits a particular error, you can use rescue, to stop the programme from ending.

Use a begin and end block to handle exceptions and use one or more rescue clauses to tell Ruby what kind of exceptions you want to handle

def raise_an_error
raise 'An error occured.'
puts 'Programme rescued.'

Anything after the raise and before the rescue won’t be run, but anything after the rescue WILL be run.

You can also put a parameter on rescue so you can tell your programme to ONLY rescue certain kinds of errors (that is, the ones you think are acceptable for the circumstances).


rescue StandardError => e

if you don’t say what kind of error, the code will assume StandardError.

rescue StandardError => e
you can shortcut it by
rescue => e
and it will assume you mean Standard Error

It’s important to note that the exception names you use are class names, so if you rescue, for example, StandardError, you will rescue any errors that inherit from that.

You can also create your own exception classes, and you probably want them to inherit from StandardError.

So for example, you probably never want to go
rescue Exception
because this will rescue every exception, because all exceptions inherit from the Exception class.

Errors that inherit from StandardError are NoMethodError, TypeError, RuntimeError, but you can see the whole Exception hierarchy like here

Testing Exceptions

assert_raise(TriangleError) do triangle(0, 0, 0) end

Tests if the given block raises an exception. Acceptable exception types maye be given as optional arguments. If the last argument is a String, it will be used as the error message.



Leave a reply

Gem Dependency Nightmares

As part of the Spree open source project I have been working on, I have encountered a more than usual number of Gem dependency issues. I put this down to the fact that Spree is a big huge project, with multiple engines, each with their own gemfile.

However, today I discovered it could also be because I have not been managing my gems effectively! I wrote a blog post on our Spree project blog, about how I should be managing my gems in the future.

Far out this is a short blog post.

Leave a reply